-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDKv2 Diff tests for primitive types (#2829)
This PR finishes the test coverage for primitive types (string, bool, int and float) for the SDKv2 bridge for Diff. [14807c6](14807c6) and [8552a4a](8552a4a) contain the test recordings. fixes #2786
- Loading branch information
1 parent
cb11d40
commit 9660285
Showing
163 changed files
with
4,175 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package tests | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/zclconf/go-cty/cty" | ||
) | ||
|
||
func TestSDKv2DetailedDiffString(t *testing.T) { | ||
t.Parallel() | ||
|
||
var nilVal string | ||
schemaValueMakerPairs, scenarios := generateBaseTests( | ||
schema.TypeString, cty.StringVal, "val1", "val2", "computed", "default", nilVal) | ||
|
||
runSDKv2TestMatrix(t, schemaValueMakerPairs, scenarios) | ||
} | ||
|
||
func TestSDKv2DetailedDiffBool(t *testing.T) { | ||
t.Parallel() | ||
|
||
var nilVal bool | ||
schemaValueMakerPairs, scenarios := generateBaseTests( | ||
schema.TypeBool, cty.BoolVal, true, false, true, false, nilVal) | ||
|
||
runSDKv2TestMatrix(t, schemaValueMakerPairs, scenarios) | ||
} | ||
|
||
func TestSDKv2DetailedDiffInt(t *testing.T) { | ||
t.Parallel() | ||
|
||
var nilVal int64 | ||
schemaValueMakerPairs, scenarios := generateBaseTests( | ||
schema.TypeInt, cty.NumberIntVal, 1, 2, 3, 4, nilVal) | ||
|
||
runSDKv2TestMatrix(t, schemaValueMakerPairs, scenarios) | ||
} | ||
|
||
func TestSDKv2DetailedDiffFloat(t *testing.T) { | ||
t.Parallel() | ||
|
||
var nilVal float64 | ||
schemaValueMakerPairs, scenarios := generateBaseTests( | ||
schema.TypeFloat, cty.NumberFloatVal, 1.0, 2.0, 3.0, 4.0, nilVal) | ||
|
||
runSDKv2TestMatrix(t, schemaValueMakerPairs, scenarios) | ||
} |
31 changes: 31 additions & 0 deletions
31
pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffBool/optional/added.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(false), changeValue: valast.Ptr(true), | ||
tfOut: ` | ||
Terraform used the selected providers to generate the following execution | ||
plan. Resource actions are indicated with the following symbols: | ||
~ update in-place | ||
|
||
Terraform will perform the following actions: | ||
|
||
# crossprovider_test_res.example will be updated in-place | ||
~ resource "crossprovider_test_res" "example" { | ||
id = "newid" | ||
~ prop = false -> true | ||
} | ||
|
||
Plan: 0 to add, 1 to change, 0 to destroy. | ||
|
||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
~ crossprovider:index/testRes:TestRes: (update) | ||
[id=newid] | ||
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] | ||
~ prop: false => true | ||
Resources: | ||
~ 1 to update | ||
1 unchanged | ||
`, | ||
detailedDiff: map[string]interface{}{"prop": map[string]interface{}{"kind": "UPDATE"}}, | ||
} |
31 changes: 31 additions & 0 deletions
31
pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffBool/optional/changed.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(true), changeValue: valast.Ptr(false), | ||
tfOut: ` | ||
Terraform used the selected providers to generate the following execution | ||
plan. Resource actions are indicated with the following symbols: | ||
~ update in-place | ||
|
||
Terraform will perform the following actions: | ||
|
||
# crossprovider_test_res.example will be updated in-place | ||
~ resource "crossprovider_test_res" "example" { | ||
id = "newid" | ||
~ prop = true -> false | ||
} | ||
|
||
Plan: 0 to add, 1 to change, 0 to destroy. | ||
|
||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
~ crossprovider:index/testRes:TestRes: (update) | ||
[id=newid] | ||
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] | ||
~ prop: true => false | ||
Resources: | ||
~ 1 to update | ||
1 unchanged | ||
`, | ||
detailedDiff: map[string]interface{}{"prop": map[string]interface{}{"kind": "UPDATE"}}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffBool/optional/unchanged_empty.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(false), changeValue: valast.Ptr(false), | ||
tfOut: ` | ||
No changes. Your infrastructure matches the configuration. | ||
|
||
Terraform has compared your real infrastructure against your configuration | ||
and found no differences, so no changes are needed. | ||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
Resources: | ||
2 unchanged | ||
`, | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffBool/optional/unchanged_non-empty.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(true), changeValue: valast.Ptr(true), | ||
tfOut: ` | ||
No changes. Your infrastructure matches the configuration. | ||
|
||
Terraform has compared your real infrastructure against your configuration | ||
and found no differences, so no changes are needed. | ||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
Resources: | ||
2 unchanged | ||
`, | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffBool/optionalComputed/added.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(false), changeValue: valast.Ptr(true), | ||
tfOut: ` | ||
No changes. Your infrastructure matches the configuration. | ||
|
||
Terraform has compared your real infrastructure against your configuration | ||
and found no differences, so no changes are needed. | ||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
Resources: | ||
2 unchanged | ||
`, | ||
} |
31 changes: 31 additions & 0 deletions
31
pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffBool/optionalComputed/changed.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(true), changeValue: valast.Ptr(false), | ||
tfOut: ` | ||
Terraform used the selected providers to generate the following execution | ||
plan. Resource actions are indicated with the following symbols: | ||
~ update in-place | ||
|
||
Terraform will perform the following actions: | ||
|
||
# crossprovider_test_res.example will be updated in-place | ||
~ resource "crossprovider_test_res" "example" { | ||
id = "id" | ||
~ prop = true -> false | ||
} | ||
|
||
Plan: 0 to add, 1 to change, 0 to destroy. | ||
|
||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
~ crossprovider:index/testRes:TestRes: (update) | ||
[id=id] | ||
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] | ||
~ prop: true => false | ||
Resources: | ||
~ 1 to update | ||
1 unchanged | ||
`, | ||
detailedDiff: map[string]interface{}{"prop": map[string]interface{}{"kind": "UPDATE"}}, | ||
} |
31 changes: 31 additions & 0 deletions
31
pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffBool/optionalComputed/removed.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(true), changeValue: valast.Ptr(false), | ||
tfOut: ` | ||
Terraform used the selected providers to generate the following execution | ||
plan. Resource actions are indicated with the following symbols: | ||
~ update in-place | ||
|
||
Terraform will perform the following actions: | ||
|
||
# crossprovider_test_res.example will be updated in-place | ||
~ resource "crossprovider_test_res" "example" { | ||
id = "id" | ||
~ prop = true -> false | ||
} | ||
|
||
Plan: 0 to add, 1 to change, 0 to destroy. | ||
|
||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
~ crossprovider:index/testRes:TestRes: (update) | ||
[id=id] | ||
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] | ||
~ prop: true => false | ||
Resources: | ||
~ 1 to update | ||
1 unchanged | ||
`, | ||
detailedDiff: map[string]interface{}{"prop": map[string]interface{}{"kind": "UPDATE"}}, | ||
} |
31 changes: 31 additions & 0 deletions
31
...ests/diff_test/testdata/TestSDKv2DetailedDiffBool/optionalComputed/unchanged_empty.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(false), changeValue: valast.Ptr(false), | ||
tfOut: ` | ||
Terraform used the selected providers to generate the following execution | ||
plan. Resource actions are indicated with the following symbols: | ||
~ update in-place | ||
|
||
Terraform will perform the following actions: | ||
|
||
# crossprovider_test_res.example will be updated in-place | ||
~ resource "crossprovider_test_res" "example" { | ||
id = "id" | ||
~ prop = true -> false | ||
} | ||
|
||
Plan: 0 to add, 1 to change, 0 to destroy. | ||
|
||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
~ crossprovider:index/testRes:TestRes: (update) | ||
[id=id] | ||
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] | ||
~ prop: true => false | ||
Resources: | ||
~ 1 to update | ||
1 unchanged | ||
`, | ||
detailedDiff: map[string]interface{}{"prop": map[string]interface{}{"kind": "UPDATE"}}, | ||
} |
15 changes: 15 additions & 0 deletions
15
.../diff_test/testdata/TestSDKv2DetailedDiffBool/optionalComputed/unchanged_non-empty.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(true), changeValue: valast.Ptr(true), | ||
tfOut: ` | ||
No changes. Your infrastructure matches the configuration. | ||
|
||
Terraform has compared your real infrastructure against your configuration | ||
and found no differences, so no changes are needed. | ||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
Resources: | ||
2 unchanged | ||
`, | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffBool/optionalComputedForceNew/added.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tests.testOutput{ | ||
initialValue: valast.Ptr(false), changeValue: valast.Ptr(true), | ||
tfOut: ` | ||
No changes. Your infrastructure matches the configuration. | ||
|
||
Terraform has compared your real infrastructure against your configuration | ||
and found no differences, so no changes are needed. | ||
`, | ||
pulumiOut: `Previewing update (test): | ||
pulumi:pulumi:Stack: (same) | ||
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] | ||
Resources: | ||
2 unchanged | ||
`, | ||
} |
Oops, something went wrong.