diff --git a/pkg/tests/diff_test/detailed_diff_map_test.go b/pkg/tests/diff_test/detailed_diff_map_test.go index 0f4b234a7..f7d0148d5 100644 --- a/pkg/tests/diff_test/detailed_diff_map_test.go +++ b/pkg/tests/diff_test/detailed_diff_map_test.go @@ -1,14 +1,10 @@ package tests import ( - "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hexops/autogold/v2" "github.com/zclconf/go-cty/cty" - - crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests" ) func TestSDKv2DetailedDiffMap(t *testing.T) { @@ -26,7 +22,7 @@ func TestSDKv2DetailedDiffMap(t *testing.T) { } var nilVal map[string]string - schemaValueMakerPairs, scenarios := generatePrimitiveSchemaValueMakerPairs( + schemaValueMakerPairs, scenarios := generateBaseTests( schema.TypeMap, &schema.Schema{Type: schema.TypeString}, ctyMaker, map[string]string{"key": "val1"}, map[string]string{"key": "val2"}, map[string]string{"key": "computedVal"}, map[string]string{"key": "defaultVal"}, nilVal) @@ -37,26 +33,5 @@ func TestSDKv2DetailedDiffMap(t *testing.T) { changeValue: ref(map[string]string{"key2": "val1"}), }) - for _, schemaValueMakerPair := range schemaValueMakerPairs { - t.Run(schemaValueMakerPair.name, func(t *testing.T) { - t.Parallel() - for _, scenario := range scenarios { - t.Run(scenario.name, func(t *testing.T) { - if strings.Contains(schemaValueMakerPair.name, "required") && - (scenario.initialValue == nil || scenario.changeValue == nil) { - t.Skip("Required fields cannot be unset") - } - t.Parallel() - diff := crosstests.Diff(t, &schemaValueMakerPair.schema, schemaValueMakerPair.valueMaker(scenario.initialValue), schemaValueMakerPair.valueMaker(scenario.changeValue)) - autogold.ExpectFile(t, testOutput{ - initialValue: scenario.initialValue, - changeValue: scenario.changeValue, - tfOut: diff.TFOut, - pulumiOut: diff.PulumiOut, - detailedDiff: diff.PulumiDiff.DetailedDiff, - }) - }) - } - }) - } + runSDKv2TestMatrix(t, schemaValueMakerPairs, scenarios) } diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/added.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/added.golden similarity index 73% rename from pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/added.golden rename to pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/added.golden index cc55fbc40..9a561c17a 100644 --- a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/added.golden +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/added.golden @@ -1,6 +1,6 @@ tests.testOutput{ - initialValue: map[string]string{}, - changeValue: map[string]string{"key": "val"}, + initialValue: &map[string]string{}, + changeValue: &map[string]string{"key": "val1"}, tfOut: ` Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: @@ -10,9 +10,9 @@ Terraform will perform the following actions: # crossprovider_test_res.example will be updated in-place ~ resource "crossprovider_test_res" "example" { - id = "newid" - + map_prop = { - + "key" = "val" + id = "newid" + + prop = { + + "key" = "val1" } } @@ -25,12 +25,12 @@ Plan: 0 to add, 1 to change, 0 to destroy. ~ crossprovider:index/testRes:TestRes: (update) [id=newid] [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] - + mapProp: { - + key: "val" + + prop: { + + key: "val1" } Resources: ~ 1 to update 1 unchanged `, - detailedDiff: map[string]interface{}{"mapProp": map[string]interface{}{}}, + detailedDiff: map[string]interface{}{"prop": map[string]interface{}{}}, } diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/value_changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/changed.golden similarity index 69% rename from pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/value_changed.golden rename to pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/changed.golden index 3edd45c2c..ab640a690 100644 --- a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/value_changed.golden +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/changed.golden @@ -1,8 +1,8 @@ tests.testOutput{ - initialValue: map[string]string{ - "key": "val", + initialValue: &map[string]string{ + "key": "val1", }, - changeValue: map[string]string{"key": "val2"}, + changeValue: &map[string]string{"key": "val2"}, tfOut: ` Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: @@ -12,9 +12,9 @@ Terraform will perform the following actions: # crossprovider_test_res.example will be updated in-place ~ resource "crossprovider_test_res" "example" { - id = "newid" - ~ map_prop = { - ~ "key" = "val" -> "val2" + id = "newid" + ~ prop = { + ~ "key" = "val1" -> "val2" } } @@ -27,12 +27,12 @@ Plan: 0 to add, 1 to change, 0 to destroy. ~ crossprovider:index/testRes:TestRes: (update) [id=newid] [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] - ~ mapProp: { - ~ key: "val" => "val2" + ~ prop: { + ~ key: "val1" => "val2" } Resources: ~ 1 to update 1 unchanged `, - detailedDiff: map[string]interface{}{"mapProp.key": map[string]interface{}{"kind": "UPDATE"}}, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}}, } diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/key_changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/key_changed.golden similarity index 68% rename from pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/key_changed.golden rename to pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/key_changed.golden index 2193f1ef6..82d0977ec 100644 --- a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/key_changed.golden +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/key_changed.golden @@ -1,8 +1,8 @@ tests.testOutput{ - initialValue: map[string]string{ - "key": "val", + initialValue: &map[string]string{ + "key": "val1", }, - changeValue: map[string]string{"key2": "val"}, + changeValue: &map[string]string{"key2": "val1"}, tfOut: ` Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: @@ -12,10 +12,10 @@ Terraform will perform the following actions: # crossprovider_test_res.example will be updated in-place ~ resource "crossprovider_test_res" "example" { - id = "newid" - ~ map_prop = { - - "key" = "val" -> null - + "key2" = "val" + id = "newid" + ~ prop = { + - "key" = "val1" -> null + + "key2" = "val1" } } @@ -28,16 +28,16 @@ Plan: 0 to add, 1 to change, 0 to destroy. ~ crossprovider:index/testRes:TestRes: (update) [id=newid] [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] - ~ mapProp: { - - key : "val" - + key2: "val" + ~ prop: { + - key : "val1" + + key2: "val1" } Resources: ~ 1 to update 1 unchanged `, detailedDiff: map[string]interface{}{ - "mapProp.key": map[string]interface{}{"kind": "DELETE"}, - "mapProp.key2": map[string]interface{}{}, + "prop.key": map[string]interface{}{"kind": "DELETE"}, + "prop.key2": map[string]interface{}{}, }, } diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/removed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/removed.golden similarity index 71% rename from pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/removed.golden rename to pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/removed.golden index 34fbfc62c..8f7234fa5 100644 --- a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/removed.golden +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/removed.golden @@ -1,8 +1,8 @@ tests.testOutput{ - initialValue: map[string]string{ - "key": "val", + initialValue: &map[string]string{ + "key": "val1", }, - changeValue: map[string]string{}, + changeValue: &map[string]string{}, tfOut: ` Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: @@ -12,9 +12,9 @@ Terraform will perform the following actions: # crossprovider_test_res.example will be updated in-place ~ resource "crossprovider_test_res" "example" { - id = "newid" - ~ map_prop = { - - "key" = "val" -> null + id = "newid" + ~ prop = { + - "key" = "val1" -> null } } @@ -27,12 +27,12 @@ Plan: 0 to add, 1 to change, 0 to destroy. ~ crossprovider:index/testRes:TestRes: (update) [id=newid] [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] - ~ mapProp: { - - key: "val" + ~ prop: { + - key: "val1" } Resources: ~ 1 to update 1 unchanged `, - detailedDiff: map[string]interface{}{"mapProp.key": map[string]interface{}{"kind": "DELETE"}}, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE"}}, } diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/unchanged_empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/unchanged_empty.golden similarity index 84% rename from pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/unchanged_empty.golden rename to pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/unchanged_empty.golden index 342ab2068..9247a8f3a 100644 --- a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/unchanged_empty.golden +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/unchanged_empty.golden @@ -1,6 +1,6 @@ tests.testOutput{ - initialValue: map[string]string{}, - changeValue: map[string]string{}, + initialValue: &map[string]string{}, + changeValue: &map[string]string{}, tfOut: ` No changes. Your infrastructure matches the configuration. diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/unchanged_non-empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/unchanged_non-empty.golden similarity index 79% rename from pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/unchanged_non-empty.golden rename to pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/unchanged_non-empty.golden index 95f4be8e3..388878119 100644 --- a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/unchanged_non-empty.golden +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optional/unchanged_non-empty.golden @@ -1,8 +1,8 @@ tests.testOutput{ - initialValue: map[string]string{ - "key": "val", + initialValue: &map[string]string{ + "key": "val1", }, - changeValue: map[string]string{"key": "val"}, + changeValue: &map[string]string{"key": "val1"}, tfOut: ` No changes. Your infrastructure matches the configuration. diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/added.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/added.golden new file mode 100644 index 000000000..8c8e71567 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/added.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{"key": "val1"}, + 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 = { + ~ "key" = "computedVal" -> "val1" + } + } + +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: { + ~ key: "computedVal" => "val1" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/changed.golden new file mode 100644 index 000000000..63ff21864 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/changed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val2"}, + 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 = { + ~ "key" = "val1" -> "val2" + } + } + +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: { + ~ key: "val1" => "val2" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/key_changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/key_changed.golden new file mode 100644 index 000000000..4c134cacc --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/key_changed.golden @@ -0,0 +1,43 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key2": "val1"}, + 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 = { + - "key" = "val1" -> null + + "key2" = "val1" + } + } + +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: { + - key : "val1" + + key2: "val1" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "prop.key": map[string]interface{}{"kind": "DELETE"}, + "prop.key2": map[string]interface{}{}, + }, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/removed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/removed.golden new file mode 100644 index 000000000..df8e01379 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/removed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{}, + 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 = { + - "key" = "val1" -> null + } + } + +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: { + - key: "val1" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/unchanged_empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/unchanged_empty.golden new file mode 100644 index 000000000..384b90b2c --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/unchanged_empty.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{}, + 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 = { + - "key" = "computedVal" -> null + } + } + +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: { + - key: "computedVal" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/unchanged_non-empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/unchanged_non-empty.golden new file mode 100644 index 000000000..388878119 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputed/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val1"}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/added.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/added.golden new file mode 100644 index 000000000..1fe50973e --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/added.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{"key": "val1"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "id" -> (known after apply) + ~ prop = { # forces replacement + ~ "key" = "computedVal" -> "val1" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=id] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + ~ key: "computedVal" => "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/changed.golden new file mode 100644 index 000000000..37e4dbaf2 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/changed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val2"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "id" -> (known after apply) + ~ prop = { # forces replacement + ~ "key" = "val1" -> "val2" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=id] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + ~ key: "val1" => "val2" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/key_changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/key_changed.golden new file mode 100644 index 000000000..af3d935c1 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/key_changed.golden @@ -0,0 +1,43 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key2": "val1"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "id" -> (known after apply) + ~ prop = { # forces replacement + - "key" = "val1" -> null + + "key2" = "val1" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=id] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + - key : "val1" + + key2: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "prop.key": map[string]interface{}{"kind": "DELETE_REPLACE"}, + "prop.key2": map[string]interface{}{"kind": "ADD_REPLACE"}, + }, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/removed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/removed.golden new file mode 100644 index 000000000..fb487d69b --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/removed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "id" -> (known after apply) + ~ prop = { + - "key" = "val1" + } -> (known after apply) # forces replacement + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=id] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + - key: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/unchanged_empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/unchanged_empty.golden new file mode 100644 index 000000000..83ebc3c9a --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/unchanged_empty.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "id" -> (known after apply) + ~ prop = { + - "key" = "computedVal" + } -> (known after apply) # forces replacement + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=id] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + - key: "computedVal" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/unchanged_non-empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/unchanged_non-empty.golden new file mode 100644 index 000000000..388878119 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalComputedForceNew/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val1"}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/added.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/added.golden new file mode 100644 index 000000000..9a561c17a --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/added.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{"key": "val1"}, + 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 = { + + "key" = "val1" + } + } + +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: { + + key: "val1" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop": map[string]interface{}{}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/changed.golden new file mode 100644 index 000000000..ab640a690 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/changed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val2"}, + 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 = { + ~ "key" = "val1" -> "val2" + } + } + +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: { + ~ key: "val1" => "val2" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/key_changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/key_changed.golden new file mode 100644 index 000000000..82d0977ec --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/key_changed.golden @@ -0,0 +1,43 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key2": "val1"}, + 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 = { + - "key" = "val1" -> null + + "key2" = "val1" + } + } + +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: { + - key : "val1" + + key2: "val1" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "prop.key": map[string]interface{}{"kind": "DELETE"}, + "prop.key2": map[string]interface{}{}, + }, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/removed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/removed.golden new file mode 100644 index 000000000..8f7234fa5 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/removed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{}, + 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 = { + - "key" = "val1" -> null + } + } + +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: { + - key: "val1" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/unchanged_empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/unchanged_empty.golden new file mode 100644 index 000000000..9247a8f3a --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/unchanged_empty.golden @@ -0,0 +1,16 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/unchanged_non-empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/unchanged_non-empty.golden new file mode 100644 index 000000000..388878119 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefault/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val1"}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/added.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/added.golden new file mode 100644 index 000000000..f25695065 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/added.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{"key": "val1"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + + prop = { # forces replacement + + "key" = "val1" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + + prop: { + + key: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/changed.golden new file mode 100644 index 000000000..343e5fe5e --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/changed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val2"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + ~ prop = { # forces replacement + ~ "key" = "val1" -> "val2" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + ~ key: "val1" => "val2" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/key_changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/key_changed.golden new file mode 100644 index 000000000..8f6b3bad1 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/key_changed.golden @@ -0,0 +1,43 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key2": "val1"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + ~ prop = { # forces replacement + - "key" = "val1" -> null + + "key2" = "val1" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + - key : "val1" + + key2: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "prop.key": map[string]interface{}{"kind": "DELETE_REPLACE"}, + "prop.key2": map[string]interface{}{"kind": "ADD_REPLACE"}, + }, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/removed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/removed.golden new file mode 100644 index 000000000..16ef25f0b --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/removed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + - prop = { # forces replacement + - "key" = "val1" + } -> null + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + - key: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/unchanged_empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/unchanged_empty.golden new file mode 100644 index 000000000..9247a8f3a --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/unchanged_empty.golden @@ -0,0 +1,16 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/unchanged_non-empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/unchanged_non-empty.golden new file mode 100644 index 000000000..388878119 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalDefaultForceNew/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val1"}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/added.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/added.golden new file mode 100644 index 000000000..f25695065 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/added.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{"key": "val1"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + + prop = { # forces replacement + + "key" = "val1" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + + prop: { + + key: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/changed.golden new file mode 100644 index 000000000..343e5fe5e --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/changed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val2"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + ~ prop = { # forces replacement + ~ "key" = "val1" -> "val2" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + ~ key: "val1" => "val2" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/key_changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/key_changed.golden new file mode 100644 index 000000000..8f6b3bad1 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/key_changed.golden @@ -0,0 +1,43 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key2": "val1"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + ~ prop = { # forces replacement + - "key" = "val1" -> null + + "key2" = "val1" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + - key : "val1" + + key2: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "prop.key": map[string]interface{}{"kind": "DELETE_REPLACE"}, + "prop.key2": map[string]interface{}{"kind": "ADD_REPLACE"}, + }, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/removed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/removed.golden new file mode 100644 index 000000000..16ef25f0b --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/removed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + - prop = { # forces replacement + - "key" = "val1" + } -> null + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + - key: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/unchanged_empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/unchanged_empty.golden new file mode 100644 index 000000000..9247a8f3a --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/unchanged_empty.golden @@ -0,0 +1,16 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/unchanged_non-empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/unchanged_non-empty.golden new file mode 100644 index 000000000..388878119 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/optionalForceNew/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val1"}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/added.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/added.golden new file mode 100644 index 000000000..9a561c17a --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/added.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{"key": "val1"}, + 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 = { + + "key" = "val1" + } + } + +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: { + + key: "val1" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop": map[string]interface{}{}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/changed.golden new file mode 100644 index 000000000..ab640a690 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/changed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val2"}, + 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 = { + ~ "key" = "val1" -> "val2" + } + } + +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: { + ~ key: "val1" => "val2" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/key_changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/key_changed.golden new file mode 100644 index 000000000..82d0977ec --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/key_changed.golden @@ -0,0 +1,43 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key2": "val1"}, + 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 = { + - "key" = "val1" -> null + + "key2" = "val1" + } + } + +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: { + - key : "val1" + + key2: "val1" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "prop.key": map[string]interface{}{"kind": "DELETE"}, + "prop.key2": map[string]interface{}{}, + }, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/removed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/removed.golden new file mode 100644 index 000000000..8f7234fa5 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/removed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{}, + 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 = { + - "key" = "val1" -> null + } + } + +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: { + - key: "val1" + } +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/unchanged_empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/unchanged_empty.golden new file mode 100644 index 000000000..9247a8f3a --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/unchanged_empty.golden @@ -0,0 +1,16 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/unchanged_non-empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/unchanged_non-empty.golden new file mode 100644 index 000000000..388878119 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/required/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val1"}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/added.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/added.golden new file mode 100644 index 000000000..f25695065 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/added.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{"key": "val1"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + + prop = { # forces replacement + + "key" = "val1" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + + prop: { + + key: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/changed.golden new file mode 100644 index 000000000..343e5fe5e --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/changed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val2"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + ~ prop = { # forces replacement + ~ "key" = "val1" -> "val2" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + ~ key: "val1" => "val2" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/key_changed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/key_changed.golden new file mode 100644 index 000000000..8f6b3bad1 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/key_changed.golden @@ -0,0 +1,43 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key2": "val1"}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + ~ prop = { # forces replacement + - "key" = "val1" -> null + + "key2" = "val1" + } + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + - key : "val1" + + key2: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "prop.key": map[string]interface{}{"kind": "DELETE_REPLACE"}, + "prop.key2": map[string]interface{}{"kind": "ADD_REPLACE"}, + }, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/removed.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/removed.golden new file mode 100644 index 000000000..16ef25f0b --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/removed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: ++/- create replacement and then destroy + +Terraform will perform the following actions: + + # crossprovider_test_res.example must be replaced ++/- resource "crossprovider_test_res" "example" { + ~ id = "newid" -> (known after apply) + - prop = { # forces replacement + - "key" = "val1" + } -> null + } + +Plan: 1 to add, 0 to change, 1 to destroy. + +`, + pulumiOut: `Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test] + +-crossprovider:index/testRes:TestRes: (replace) + [id=newid] + [urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example] + ~ prop: { + - key: "val1" + } +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/unchanged_empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/unchanged_empty.golden new file mode 100644 index 000000000..9247a8f3a --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/unchanged_empty.golden @@ -0,0 +1,16 @@ +tests.testOutput{ + initialValue: &map[string]string{}, + changeValue: &map[string]string{}, + 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 +`, +} diff --git a/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/unchanged_non-empty.golden b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/unchanged_non-empty.golden new file mode 100644 index 000000000..388878119 --- /dev/null +++ b/pkg/tests/diff_test/testdata/TestSDKv2DetailedDiffMap/requiredForceNew/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &map[string]string{ + "key": "val1", + }, + changeValue: &map[string]string{"key": "val1"}, + 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 +`, +} diff --git a/pkg/tests/diff_test/value_makers.go b/pkg/tests/diff_test/value_makers.go index ef561714d..c907423df 100644 --- a/pkg/tests/diff_test/value_makers.go +++ b/pkg/tests/diff_test/value_makers.go @@ -78,7 +78,7 @@ func generateBaseTests[T any]( Schema: map[string]*schema.Schema{ "prop": { Type: typ, - Elem: elem, + Elem: elem, Optional: true, }, },