11package port
22
33import (
4+ "fmt"
45 "testing"
56
67 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
78 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
89)
910
1011func TestAccPortEntityUpdateProp (t * testing.T ) {
11- var testAccActionConfigCreate = `
12+ identifier := genID ()
13+ var testAccActionConfigCreate = fmt .Sprintf (`
1214 provider "port-labs" {}
15+ resource "port-labs_blueprint" "tf_bp" {
16+ title = "TF Provider Test"
17+ icon = "Terraform"
18+ identifier = "%s"
19+ properties {
20+ identifier = "text"
21+ type = "string"
22+ title = "text"
23+ }
24+ }
1325 resource "port-labs_entity" "microservice" {
1426 title = "monolith"
15- blueprint = "tf-provider-test-bp"
27+ blueprint = port-labs_blueprint.tf_bp.id
1628 properties {
1729 name = "text"
1830 value = "hedwig"
1931 }
2032 }
21- `
22- var testAccActionConfigUpdate = `
33+ ` , identifier )
34+ var testAccActionConfigUpdate = fmt . Sprintf ( `
2335 provider "port-labs" {}
36+ resource "port-labs_blueprint" "tf_bp" {
37+ title = "TF Provider Test"
38+ icon = "Terraform"
39+ identifier = "%s"
40+ properties {
41+ identifier = "text"
42+ type = "string"
43+ title = "text"
44+ }
45+ }
2446 resource "port-labs_entity" "microservice" {
2547 title = "monolith"
26- blueprint = "tf-provider-test-bp"
48+ blueprint = port-labs_blueprint.tf_bp.id
2749 properties {
2850 name = "text"
2951 value = "hedwig2"
3052 }
3153 }
32- `
54+ ` , identifier )
3355 resource .Test (t , resource.TestCase {
3456 Providers : map [string ]* schema.Provider {
3557 "port-labs" : Provider (),
@@ -47,8 +69,39 @@ func TestAccPortEntityUpdateProp(t *testing.T) {
4769}
4870
4971func TestAccPortEntity (t * testing.T ) {
50- var testAccActionConfigCreate = `
72+ identifier := genID ()
73+ var testAccActionConfigCreate = fmt .Sprintf (`
5174 provider "port-labs" {}
75+ resource "port-labs_blueprint" "microservice" {
76+ title = "TF Provider Test BP0"
77+ icon = "Terraform"
78+ identifier = "%s"
79+ properties {
80+ identifier = "text"
81+ type = "string"
82+ title = "text"
83+ }
84+ properties {
85+ identifier = "bool"
86+ type = "boolean"
87+ title = "boolean"
88+ }
89+ properties {
90+ identifier = "num"
91+ type = "number"
92+ title = "number"
93+ }
94+ properties {
95+ identifier = "obj"
96+ type = "object"
97+ title = "object"
98+ }
99+ properties {
100+ identifier = "arr"
101+ type = "array"
102+ title = "array"
103+ }
104+ }
52105 resource "port-labs_entity" "microservice" {
53106 title = "monolith"
54107 blueprint = "tf-provider-test-bp"
@@ -73,7 +126,7 @@ func TestAccPortEntity(t *testing.T) {
73126 value = jsonencode({"a":"b"})
74127 }
75128 }
76- `
129+ ` , identifier )
77130 resource .Test (t , resource.TestCase {
78131 Providers : map [string ]* schema.Provider {
79132 "port-labs" : Provider (),
@@ -87,11 +140,38 @@ func TestAccPortEntity(t *testing.T) {
87140}
88141
89142func TestAccPortEntitiesRelation (t * testing.T ) {
90- var testAccActionConfigCreate = `
143+ identifier1 := genID ()
144+ identifier2 := genID ()
145+ var testAccActionConfigCreate = fmt .Sprintf (`
91146 provider "port-labs" {}
147+ resource "port-labs_blueprint" "microservice" {
148+ title = "TF Provider Test BP0"
149+ icon = "Terraform"
150+ identifier = "%s"
151+ properties {
152+ identifier = "text"
153+ type = "string"
154+ title = "text"
155+ }
156+ relations {
157+ identifier = "tf-relation"
158+ title = "Test Relation"
159+ target = port-labs_blueprint.microservice2.identifier
160+ }
161+ }
162+ resource "port-labs_blueprint" "microservice2" {
163+ title = "TF Provider Test BP0"
164+ icon = "Terraform"
165+ identifier = "%s"
166+ properties {
167+ identifier = "str"
168+ type = "string"
169+ title = "text"
170+ }
171+ }
92172 resource "port-labs_entity" "microservice" {
93173 title = "monolith"
94- blueprint = "tf-provider-test-bp"
174+ blueprint = port-labs_blueprint.microservice.id
95175 relations {
96176 name = "tf-relation"
97177 identifier = port-labs_entity.microservice2.id
@@ -103,13 +183,13 @@ func TestAccPortEntitiesRelation(t *testing.T) {
103183 }
104184 resource "port-labs_entity" "microservice2" {
105185 title = "monolith2"
106- blueprint = "tf-provider-test-bp2"
186+ blueprint = port-labs_blueprint.microservice2.id
107187 properties {
108188 name = "str"
109189 value = "test-relation"
110190 }
111191 }
112- `
192+ ` , identifier1 , identifier2 )
113193 resource .Test (t , resource.TestCase {
114194 Providers : map [string ]* schema.Provider {
115195 "port-labs" : Provider (),
0 commit comments