Skip to content

Commit

Permalink
decouple tests from pre-configured blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
hedwigz committed Aug 29, 2022
1 parent a049149 commit fc19404
Showing 1 changed file with 92 additions and 12 deletions.
104 changes: 92 additions & 12 deletions port/resource_port_entity_test.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,57 @@
package port

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func TestAccPortEntityUpdateProp(t *testing.T) {
var testAccActionConfigCreate = `
identifier := genID()
var testAccActionConfigCreate = fmt.Sprintf(`
provider "port-labs" {}
resource "port-labs_blueprint" "tf_bp" {
title = "TF Provider Test"
icon = "Terraform"
identifier = "%s"
properties {
identifier = "text"
type = "string"
title = "text"
}
}
resource "port-labs_entity" "microservice" {
title = "monolith"
blueprint = "tf-provider-test-bp"
blueprint = port-labs_blueprint.tf_bp.id
properties {
name = "text"
value = "hedwig"
}
}
`
var testAccActionConfigUpdate = `
`, identifier)
var testAccActionConfigUpdate = fmt.Sprintf(`
provider "port-labs" {}
resource "port-labs_blueprint" "tf_bp" {
title = "TF Provider Test"
icon = "Terraform"
identifier = "%s"
properties {
identifier = "text"
type = "string"
title = "text"
}
}
resource "port-labs_entity" "microservice" {
title = "monolith"
blueprint = "tf-provider-test-bp"
blueprint = port-labs_blueprint.tf_bp.id
properties {
name = "text"
value = "hedwig2"
}
}
`
`, identifier)
resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
"port-labs": Provider(),
Expand All @@ -47,8 +69,39 @@ func TestAccPortEntityUpdateProp(t *testing.T) {
}

func TestAccPortEntity(t *testing.T) {
var testAccActionConfigCreate = `
identifier := genID()
var testAccActionConfigCreate = fmt.Sprintf(`
provider "port-labs" {}
resource "port-labs_blueprint" "microservice" {
title = "TF Provider Test BP0"
icon = "Terraform"
identifier = "%s"
properties {
identifier = "text"
type = "string"
title = "text"
}
properties {
identifier = "bool"
type = "boolean"
title = "boolean"
}
properties {
identifier = "num"
type = "number"
title = "number"
}
properties {
identifier = "obj"
type = "object"
title = "object"
}
properties {
identifier = "arr"
type = "array"
title = "array"
}
}
resource "port-labs_entity" "microservice" {
title = "monolith"
blueprint = "tf-provider-test-bp"
Expand All @@ -73,7 +126,7 @@ func TestAccPortEntity(t *testing.T) {
value = jsonencode({"a":"b"})
}
}
`
`, identifier)
resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
"port-labs": Provider(),
Expand All @@ -87,11 +140,38 @@ func TestAccPortEntity(t *testing.T) {
}

func TestAccPortEntitiesRelation(t *testing.T) {
var testAccActionConfigCreate = `
identifier1 := genID()
identifier2 := genID()
var testAccActionConfigCreate = fmt.Sprintf(`
provider "port-labs" {}
resource "port-labs_blueprint" "microservice" {
title = "TF Provider Test BP0"
icon = "Terraform"
identifier = "%s"
properties {
identifier = "text"
type = "string"
title = "text"
}
relations {
identifier = "tf-relation"
title = "Test Relation"
target = port-labs_blueprint.microservice2.identifier
}
}
resource "port-labs_blueprint" "microservice2" {
title = "TF Provider Test BP0"
icon = "Terraform"
identifier = "%s"
properties {
identifier = "str"
type = "string"
title = "text"
}
}
resource "port-labs_entity" "microservice" {
title = "monolith"
blueprint = "tf-provider-test-bp"
blueprint = port-labs_blueprint.microservice.id
relations {
name = "tf-relation"
identifier = port-labs_entity.microservice2.id
Expand All @@ -103,13 +183,13 @@ func TestAccPortEntitiesRelation(t *testing.T) {
}
resource "port-labs_entity" "microservice2" {
title = "monolith2"
blueprint = "tf-provider-test-bp2"
blueprint = port-labs_blueprint.microservice2.id
properties {
name = "str"
value = "test-relation"
}
}
`
`, identifier1, identifier2)
resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
"port-labs": Provider(),
Expand Down

0 comments on commit fc19404

Please sign in to comment.