Skip to content

Commit 86c44b9

Browse files
recordings
1 parent d9846f0 commit 86c44b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1409
-71
lines changed
Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
package tests
22

33
import (
4-
"strings"
54
"testing"
65

76
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
8-
"github.com/hexops/autogold/v2"
97
"github.com/zclconf/go-cty/cty"
10-
11-
crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests"
128
)
139

1410
func TestSDKv2DetailedDiffMap(t *testing.T) {
@@ -26,7 +22,7 @@ func TestSDKv2DetailedDiffMap(t *testing.T) {
2622
}
2723

2824
var nilVal map[string]string
29-
schemaValueMakerPairs, scenarios := generatePrimitiveSchemaValueMakerPairs(
25+
schemaValueMakerPairs, scenarios := generateBaseTests(
3026
schema.TypeMap, &schema.Schema{Type: schema.TypeString}, ctyMaker,
3127
map[string]string{"key": "val1"}, map[string]string{"key": "val2"},
3228
map[string]string{"key": "computedVal"}, map[string]string{"key": "defaultVal"}, nilVal)
@@ -37,26 +33,5 @@ func TestSDKv2DetailedDiffMap(t *testing.T) {
3733
changeValue: ref(map[string]string{"key2": "val1"}),
3834
})
3935

40-
for _, schemaValueMakerPair := range schemaValueMakerPairs {
41-
t.Run(schemaValueMakerPair.name, func(t *testing.T) {
42-
t.Parallel()
43-
for _, scenario := range scenarios {
44-
t.Run(scenario.name, func(t *testing.T) {
45-
if strings.Contains(schemaValueMakerPair.name, "required") &&
46-
(scenario.initialValue == nil || scenario.changeValue == nil) {
47-
t.Skip("Required fields cannot be unset")
48-
}
49-
t.Parallel()
50-
diff := crosstests.Diff(t, &schemaValueMakerPair.schema, schemaValueMakerPair.valueMaker(scenario.initialValue), schemaValueMakerPair.valueMaker(scenario.changeValue))
51-
autogold.ExpectFile(t, testOutput{
52-
initialValue: scenario.initialValue,
53-
changeValue: scenario.changeValue,
54-
tfOut: diff.TFOut,
55-
pulumiOut: diff.PulumiOut,
56-
detailedDiff: diff.PulumiDiff.DetailedDiff,
57-
})
58-
})
59-
}
60-
})
61-
}
36+
runSDKv2TestMatrix(t, schemaValueMakerPairs, scenarios)
6237
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
tests.testOutput{
2-
initialValue: map[string]string{},
3-
changeValue: map[string]string{"key": "val"},
2+
initialValue: &map[string]string{},
3+
changeValue: &map[string]string{"key": "val1"},
44
tfOut: `
55
Terraform used the selected providers to generate the following execution
66
plan. Resource actions are indicated with the following symbols:
@@ -10,9 +10,9 @@ Terraform will perform the following actions:
1010

1111
# crossprovider_test_res.example will be updated in-place
1212
~ resource "crossprovider_test_res" "example" {
13-
id = "newid"
14-
+ map_prop = {
15-
+ "key" = "val"
13+
id = "newid"
14+
+ prop = {
15+
+ "key" = "val1"
1616
}
1717
}
1818

@@ -25,12 +25,12 @@ Plan: 0 to add, 1 to change, 0 to destroy.
2525
~ crossprovider:index/testRes:TestRes: (update)
2626
[id=newid]
2727
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
28-
+ mapProp: {
29-
+ key: "val"
28+
+ prop: {
29+
+ key: "val1"
3030
}
3131
Resources:
3232
~ 1 to update
3333
1 unchanged
3434
`,
35-
detailedDiff: map[string]interface{}{"mapProp": map[string]interface{}{}},
35+
detailedDiff: map[string]interface{}{"prop": map[string]interface{}{}},
3636
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
tests.testOutput{
2-
initialValue: map[string]string{
3-
"key": "val",
2+
initialValue: &map[string]string{
3+
"key": "val1",
44
},
5-
changeValue: map[string]string{"key": "val2"},
5+
changeValue: &map[string]string{"key": "val2"},
66
tfOut: `
77
Terraform used the selected providers to generate the following execution
88
plan. Resource actions are indicated with the following symbols:
@@ -12,9 +12,9 @@ Terraform will perform the following actions:
1212

1313
# crossprovider_test_res.example will be updated in-place
1414
~ resource "crossprovider_test_res" "example" {
15-
id = "newid"
16-
~ map_prop = {
17-
~ "key" = "val" -> "val2"
15+
id = "newid"
16+
~ prop = {
17+
~ "key" = "val1" -> "val2"
1818
}
1919
}
2020

@@ -27,12 +27,12 @@ Plan: 0 to add, 1 to change, 0 to destroy.
2727
~ crossprovider:index/testRes:TestRes: (update)
2828
[id=newid]
2929
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
30-
~ mapProp: {
31-
~ key: "val" => "val2"
30+
~ prop: {
31+
~ key: "val1" => "val2"
3232
}
3333
Resources:
3434
~ 1 to update
3535
1 unchanged
3636
`,
37-
detailedDiff: map[string]interface{}{"mapProp.key": map[string]interface{}{"kind": "UPDATE"}},
37+
detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}},
3838
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
tests.testOutput{
2-
initialValue: map[string]string{
3-
"key": "val",
2+
initialValue: &map[string]string{
3+
"key": "val1",
44
},
5-
changeValue: map[string]string{"key2": "val"},
5+
changeValue: &map[string]string{"key2": "val1"},
66
tfOut: `
77
Terraform used the selected providers to generate the following execution
88
plan. Resource actions are indicated with the following symbols:
@@ -12,10 +12,10 @@ Terraform will perform the following actions:
1212

1313
# crossprovider_test_res.example will be updated in-place
1414
~ resource "crossprovider_test_res" "example" {
15-
id = "newid"
16-
~ map_prop = {
17-
- "key" = "val" -> null
18-
+ "key2" = "val"
15+
id = "newid"
16+
~ prop = {
17+
- "key" = "val1" -> null
18+
+ "key2" = "val1"
1919
}
2020
}
2121

@@ -28,16 +28,16 @@ Plan: 0 to add, 1 to change, 0 to destroy.
2828
~ crossprovider:index/testRes:TestRes: (update)
2929
[id=newid]
3030
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
31-
~ mapProp: {
32-
- key : "val"
33-
+ key2: "val"
31+
~ prop: {
32+
- key : "val1"
33+
+ key2: "val1"
3434
}
3535
Resources:
3636
~ 1 to update
3737
1 unchanged
3838
`,
3939
detailedDiff: map[string]interface{}{
40-
"mapProp.key": map[string]interface{}{"kind": "DELETE"},
41-
"mapProp.key2": map[string]interface{}{},
40+
"prop.key": map[string]interface{}{"kind": "DELETE"},
41+
"prop.key2": map[string]interface{}{},
4242
},
4343
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
tests.testOutput{
2-
initialValue: map[string]string{
3-
"key": "val",
2+
initialValue: &map[string]string{
3+
"key": "val1",
44
},
5-
changeValue: map[string]string{},
5+
changeValue: &map[string]string{},
66
tfOut: `
77
Terraform used the selected providers to generate the following execution
88
plan. Resource actions are indicated with the following symbols:
@@ -12,9 +12,9 @@ Terraform will perform the following actions:
1212

1313
# crossprovider_test_res.example will be updated in-place
1414
~ resource "crossprovider_test_res" "example" {
15-
id = "newid"
16-
~ map_prop = {
17-
- "key" = "val" -> null
15+
id = "newid"
16+
~ prop = {
17+
- "key" = "val1" -> null
1818
}
1919
}
2020

@@ -27,12 +27,12 @@ Plan: 0 to add, 1 to change, 0 to destroy.
2727
~ crossprovider:index/testRes:TestRes: (update)
2828
[id=newid]
2929
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
30-
~ mapProp: {
31-
- key: "val"
30+
~ prop: {
31+
- key: "val1"
3232
}
3333
Resources:
3434
~ 1 to update
3535
1 unchanged
3636
`,
37-
detailedDiff: map[string]interface{}{"mapProp.key": map[string]interface{}{"kind": "DELETE"}},
37+
detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE"}},
3838
}

pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/unchanged_empty.golden renamed to pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/unchanged_empty.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
tests.testOutput{
2-
initialValue: map[string]string{},
3-
changeValue: map[string]string{},
2+
initialValue: &map[string]string{},
3+
changeValue: &map[string]string{},
44
tfOut: `
55
No changes. Your infrastructure matches the configuration.
66

pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/unchanged_non-empty.golden renamed to pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/unchanged_non-empty.golden

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
tests.testOutput{
2-
initialValue: map[string]string{
3-
"key": "val",
2+
initialValue: &map[string]string{
3+
"key": "val1",
44
},
5-
changeValue: map[string]string{"key": "val"},
5+
changeValue: &map[string]string{"key": "val1"},
66
tfOut: `
77
No changes. Your infrastructure matches the configuration.
88

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
tests.testOutput{
2+
initialValue: &map[string]string{},
3+
changeValue: &map[string]string{"key": "val1"},
4+
tfOut: `
5+
Terraform used the selected providers to generate the following execution
6+
plan. Resource actions are indicated with the following symbols:
7+
~ update in-place
8+
9+
Terraform will perform the following actions:
10+
11+
# crossprovider_test_res.example will be updated in-place
12+
~ resource "crossprovider_test_res" "example" {
13+
id = "id"
14+
~ prop = {
15+
~ "key" = "computedVal" -> "val1"
16+
}
17+
}
18+
19+
Plan: 0 to add, 1 to change, 0 to destroy.
20+
21+
`,
22+
pulumiOut: `Previewing update (test):
23+
pulumi:pulumi:Stack: (same)
24+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
25+
~ crossprovider:index/testRes:TestRes: (update)
26+
[id=id]
27+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
28+
~ prop: {
29+
~ key: "computedVal" => "val1"
30+
}
31+
Resources:
32+
~ 1 to update
33+
1 unchanged
34+
`,
35+
detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}},
36+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
tests.testOutput{
2+
initialValue: &map[string]string{
3+
"key": "val1",
4+
},
5+
changeValue: &map[string]string{"key": "val2"},
6+
tfOut: `
7+
Terraform used the selected providers to generate the following execution
8+
plan. Resource actions are indicated with the following symbols:
9+
~ update in-place
10+
11+
Terraform will perform the following actions:
12+
13+
# crossprovider_test_res.example will be updated in-place
14+
~ resource "crossprovider_test_res" "example" {
15+
id = "id"
16+
~ prop = {
17+
~ "key" = "val1" -> "val2"
18+
}
19+
}
20+
21+
Plan: 0 to add, 1 to change, 0 to destroy.
22+
23+
`,
24+
pulumiOut: `Previewing update (test):
25+
pulumi:pulumi:Stack: (same)
26+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
27+
~ crossprovider:index/testRes:TestRes: (update)
28+
[id=id]
29+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
30+
~ prop: {
31+
~ key: "val1" => "val2"
32+
}
33+
Resources:
34+
~ 1 to update
35+
1 unchanged
36+
`,
37+
detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}},
38+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
tests.testOutput{
2+
initialValue: &map[string]string{
3+
"key": "val1",
4+
},
5+
changeValue: &map[string]string{"key2": "val1"},
6+
tfOut: `
7+
Terraform used the selected providers to generate the following execution
8+
plan. Resource actions are indicated with the following symbols:
9+
~ update in-place
10+
11+
Terraform will perform the following actions:
12+
13+
# crossprovider_test_res.example will be updated in-place
14+
~ resource "crossprovider_test_res" "example" {
15+
id = "id"
16+
~ prop = {
17+
- "key" = "val1" -> null
18+
+ "key2" = "val1"
19+
}
20+
}
21+
22+
Plan: 0 to add, 1 to change, 0 to destroy.
23+
24+
`,
25+
pulumiOut: `Previewing update (test):
26+
pulumi:pulumi:Stack: (same)
27+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
28+
~ crossprovider:index/testRes:TestRes: (update)
29+
[id=id]
30+
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
31+
~ prop: {
32+
- key : "val1"
33+
+ key2: "val1"
34+
}
35+
Resources:
36+
~ 1 to update
37+
1 unchanged
38+
`,
39+
detailedDiff: map[string]interface{}{
40+
"prop.key": map[string]interface{}{"kind": "DELETE"},
41+
"prop.key2": map[string]interface{}{},
42+
},
43+
}

0 commit comments

Comments
 (0)