From c9b0de6fbe1bcfc1e947744dec2b653c95a86ffa Mon Sep 17 00:00:00 2001 From: Venelin Date: Thu, 12 Dec 2024 11:58:08 +0000 Subject: [PATCH] Add SDKv2 Detailed Diff tests for list replacements --- pkg/tests/detailed_diff_list_test.go | 108 ++++++++++++++++++ .../added_empty.golden | 15 +++ .../added_non-empty.golden | 37 ++++++ .../list_attribute_force_new/changed.golden | 38 ++++++ .../list_element_added_back.golden | 45 ++++++++ .../list_element_added_front.golden | 51 +++++++++ .../list_element_added_middle.golden | 49 ++++++++ .../list_element_removed_end.golden | 52 +++++++++ .../list_element_removed_front.golden | 50 ++++++++ .../list_element_removed_middle.golden | 52 +++++++++ .../removed_empty.golden | 15 +++ .../removed_non-empty.golden | 37 ++++++ .../unchanged_empty.golden | 11 ++ .../unchanged_non-empty.golden | 18 +++ .../list_block_force_new/added_empty.golden | 15 +++ .../added_non-empty.golden | 40 +++++++ .../list_block_force_new/changed.golden | 41 +++++++ .../list_element_added_back.golden | 48 ++++++++ .../list_element_added_front.golden | 62 ++++++++++ .../list_element_added_middle.golden | 57 +++++++++ .../list_element_removed_end.golden | 62 ++++++++++ .../list_element_removed_front.golden | 57 +++++++++ .../list_element_removed_middle.golden | 62 ++++++++++ .../list_block_force_new/removed_empty.golden | 15 +++ .../removed_non-empty.golden | 40 +++++++ .../unchanged_empty.golden | 11 ++ .../unchanged_non-empty.golden | 18 +++ .../added_empty.golden | 15 +++ .../added_non-empty.golden | 35 ++++++ .../changed.golden | 36 ++++++ .../removed_empty.golden | 15 +++ .../removed_non-empty.golden | 35 ++++++ .../unchanged_empty.golden | 11 ++ .../unchanged_non-empty.golden | 18 +++ 34 files changed, 1271 insertions(+) create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/added_empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/added_non-empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/changed.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_back.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_front.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_middle.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_end.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_front.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_middle.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/removed_empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/removed_non-empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/unchanged_empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/unchanged_non-empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/added_empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/added_non-empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/changed.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_back.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_front.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_middle.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_end.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_front.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_middle.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/removed_empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/removed_non-empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/unchanged_empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/unchanged_non-empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/added_empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/added_non-empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/changed.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/removed_empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/removed_non-empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/unchanged_empty.golden create mode 100644 pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/unchanged_non-empty.golden diff --git a/pkg/tests/detailed_diff_list_test.go b/pkg/tests/detailed_diff_list_test.go index 493cc6258..166a9ad70 100644 --- a/pkg/tests/detailed_diff_list_test.go +++ b/pkg/tests/detailed_diff_list_test.go @@ -23,6 +23,17 @@ func TestDetailedDiffList(t *testing.T) { }, } + listAttrSchemaForceNew := schema.Resource{ + Schema: map[string]*schema.Schema{ + "list_attr": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + }, + }, + } + maxItemsOneAttrSchema := schema.Resource{ Schema: map[string]*schema.Schema{ "list_attr": { @@ -34,6 +45,18 @@ func TestDetailedDiffList(t *testing.T) { }, } + maxItemsOneAttrSchemaForceNew := schema.Resource{ + Schema: map[string]*schema.Schema{ + "list_attr": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + }, + }, + } + listBlockSchema := schema.Resource{ Schema: map[string]*schema.Schema{ "list_block": { @@ -51,6 +74,43 @@ func TestDetailedDiffList(t *testing.T) { }, } + listBlockSchemaForceNew := schema.Resource{ + Schema: map[string]*schema.Schema{ + "list_block": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "prop": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } + + listBlockSchemaNestedForceNew := schema.Resource{ + Schema: map[string]*schema.Schema{ + "list_block": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "nested_prop": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + }, + }, + }, + }, + } + _ = listBlockSchemaNestedForceNew + maxItemsOneBlockSchema := schema.Resource{ Schema: map[string]*schema.Schema{ "list_block": { @@ -69,6 +129,46 @@ func TestDetailedDiffList(t *testing.T) { }, } + maxItemsOneBlockSchemaForceNew := schema.Resource{ + Schema: map[string]*schema.Schema{ + "list_block": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "nested_prop": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + } + _ = maxItemsOneBlockSchemaForceNew + + maxItemsOneBlockSchemaNestedForceNew := schema.Resource{ + Schema: map[string]*schema.Schema{ + "list_block": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "nested_prop": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + }, + }, + }, + }, + } + _ = maxItemsOneBlockSchemaNestedForceNew + attrList := func(arr *[]string) map[string]cty.Value { if arr == nil { return map[string]cty.Value{} @@ -135,7 +235,11 @@ func TestDetailedDiffList(t *testing.T) { valueMaker func(*[]string) map[string]cty.Value }{ {"list attribute", listAttrSchema, attrList}, + {"list attribute force new", listAttrSchemaForceNew, attrList}, {"list block", listBlockSchema, blockList}, + {"list block force new", listBlockSchemaForceNew, blockList}, + // TODO[pulumi/pulumi-terraform-bridge#2726]: These tests fail to produce the correct replacement plan + // {"list block nested force new", listBlockSchemaNestedForceNew, blockList}, } maxItemsOnePairs := []struct { @@ -144,7 +248,11 @@ func TestDetailedDiffList(t *testing.T) { valueMaker func(*[]string) map[string]cty.Value }{ {"max items one attribute", maxItemsOneAttrSchema, attrList}, + {"max items one attribute force new", maxItemsOneAttrSchemaForceNew, attrList}, {"max items one block", maxItemsOneBlockSchema, nestedBlockList}, + // TODO[pulumi/pulumi-terraform-bridge#2726]: These tests fail to produce the correct replacement plan + // {"max items one block force new", maxItemsOneBlockSchemaForceNew, nestedBlockList}, + // {"max items one block nested force new", maxItemsOneBlockSchemaNestedForceNew, nestedBlockList}, } oneElementScenarios := []struct { diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/added_empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/added_empty.golden new file mode 100644 index 000000000..9589fbdf0 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/added_empty.golden @@ -0,0 +1,15 @@ +tests.testOutput{ + changeValue: &[]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/testdata/TestDetailedDiffList/list_attribute_force_new/added_non-empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/added_non-empty.golden new file mode 100644 index 000000000..cd609ef34 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/added_non-empty.golden @@ -0,0 +1,37 @@ +tests.testOutput{ + changeValue: &[]string{ + "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) + + list_attr = [ # forces replacement + + "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] + + listAttrs: [ + + [0]: "val1" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttrs": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/changed.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/changed.golden new file mode 100644 index 000000000..48e3d2338 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/changed.golden @@ -0,0 +1,38 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + }, + changeValue: &[]string{"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) + ~ list_attr = [ # forces replacement + ~ "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] + ~ listAttrs: [ + ~ [0]: "val1" => "val2" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttrs[0]": map[string]interface{}{"kind": "UPDATE_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_back.golden new file mode 100644 index 000000000..5d48729c4 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_back.golden @@ -0,0 +1,45 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + }, + changeValue: &[]string{ + "val1", + "val2", + "val3", + }, + 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) + ~ list_attr = [ # forces replacement + # (1 unchanged element hidden) + "val2", + + "val3", + ] + } + +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] + ~ listAttrs: [ + + [2]: "val3" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttrs[2]": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_front.golden new file mode 100644 index 000000000..27cc4f86f --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_front.golden @@ -0,0 +1,51 @@ +tests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + }, + changeValue: &[]string{ + "val1", + "val2", + "val3", + }, + 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) + ~ list_attr = [ # forces replacement + + "val1", + "val2", + # (1 unchanged element hidden) + ] + } + +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] + ~ listAttrs: [ + ~ [0]: "val2" => "val1" + ~ [1]: "val3" => "val2" + + [2]: "val3" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[0]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[1]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[2]": map[string]interface{}{"kind": "ADD_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_middle.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_middle.golden new file mode 100644 index 000000000..7d7ef68aa --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_added_middle.golden @@ -0,0 +1,49 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val3", + }, + changeValue: &[]string{ + "val1", + "val2", + "val3", + }, + 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) + ~ list_attr = [ # forces replacement + "val1", + + "val2", + "val3", + ] + } + +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] + ~ listAttrs: [ + ~ [1]: "val3" => "val2" + + [2]: "val3" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[1]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[2]": map[string]interface{}{"kind": "ADD_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_end.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_end.golden new file mode 100644 index 000000000..8edd22139 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_end.golden @@ -0,0 +1,52 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "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) + ~ list_attr = [ # forces replacement + - "val1", + "val2", + - "val3", + + "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] + ~ listAttrs: [ + ~ [0]: "val1" => "val2" + ~ [1]: "val2" => "val1" + - [2]: "val3" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[0]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[1]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[2]": map[string]interface{}{"kind": "DELETE_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_front.golden new file mode 100644 index 000000000..e171ece6c --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_front.golden @@ -0,0 +1,50 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val3", + "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) + ~ list_attr = [ # forces replacement + - "val1", + - "val2", + "val3", + + "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] + ~ listAttrs: [ + ~ [0]: "val1" => "val3" + - [2]: "val3" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[0]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[2]": map[string]interface{}{"kind": "DELETE_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_middle.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_middle.golden new file mode 100644 index 000000000..134bbf98e --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/list_element_removed_middle.golden @@ -0,0 +1,52 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val3", + "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) + ~ list_attr = [ # forces replacement + - "val1", + - "val2", + "val3", + + "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] + ~ listAttrs: [ + ~ [0]: "val1" => "val3" + ~ [1]: "val2" => "val1" + - [2]: "val3" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[0]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[1]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[2]": map[string]interface{}{"kind": "DELETE_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/removed_empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/removed_empty.golden new file mode 100644 index 000000000..7bae19762 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/removed_empty.golden @@ -0,0 +1,15 @@ +tests.testOutput{ + initialValue: &[]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/testdata/TestDetailedDiffList/list_attribute_force_new/removed_non-empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/removed_non-empty.golden new file mode 100644 index 000000000..68a7430f8 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/removed_non-empty.golden @@ -0,0 +1,37 @@ +tests.testOutput{ + initialValue: &[]string{ + "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) + - list_attr = [ # forces replacement + - "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] + - listAttrs: [ + - [0]: "val1" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttrs": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/unchanged_empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/unchanged_empty.golden new file mode 100644 index 000000000..a53fac34d --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/unchanged_empty.golden @@ -0,0 +1,11 @@ +tests.testOutput{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/testdata/TestDetailedDiffList/list_attribute_force_new/unchanged_non-empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/unchanged_non-empty.golden new file mode 100644 index 000000000..e250a9f9c --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + }, + changeValue: &[]string{"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/testdata/TestDetailedDiffList/list_block_force_new/added_empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/added_empty.golden new file mode 100644 index 000000000..9589fbdf0 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/added_empty.golden @@ -0,0 +1,15 @@ +tests.testOutput{ + changeValue: &[]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/testdata/TestDetailedDiffList/list_block_force_new/added_non-empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/added_non-empty.golden new file mode 100644 index 000000000..83661c298 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/added_non-empty.golden @@ -0,0 +1,40 @@ +tests.testOutput{ + changeValue: &[]string{ + "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) + + + list_block { # forces replacement + + prop = "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] + + listBlocks: [ + + [0]: { + + prop : "val1" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listBlocks": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/changed.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/changed.golden new file mode 100644 index 000000000..b2bedc1d1 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/changed.golden @@ -0,0 +1,41 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + }, + changeValue: &[]string{"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" + + ~ list_block { + ~ prop = "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] + ~ listBlocks: [ + ~ [0]: { + ~ prop: "val1" => "val2" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_back.golden new file mode 100644 index 000000000..6f65e800c --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_back.golden @@ -0,0 +1,48 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + }, + changeValue: &[]string{ + "val1", + "val2", + "val3", + }, + 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) + + + list_block { # forces replacement + + prop = "val3" + } + + # (2 unchanged blocks hidden) + } + +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] + ~ listBlocks: [ + + [2]: { + + prop : "val3" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listBlocks[2]": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_front.golden new file mode 100644 index 000000000..db3969bd2 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_front.golden @@ -0,0 +1,62 @@ +tests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + }, + changeValue: &[]string{ + "val1", + "val2", + "val3", + }, + 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) + + ~ list_block { # forces replacement + ~ prop = "val2" -> "val1" + } + ~ list_block { # forces replacement + ~ prop = "val3" -> "val2" + } + + list_block { # forces replacement + + prop = "val3" + } + } + +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] + ~ listBlocks: [ + ~ [0]: { + ~ prop: "val2" => "val1" + } + ~ [1]: { + ~ prop: "val3" => "val2" + } + + [2]: { + + prop : "val3" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[2]": map[string]interface{}{"kind": "ADD_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_middle.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_middle.golden new file mode 100644 index 000000000..702605e95 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_added_middle.golden @@ -0,0 +1,57 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val3", + }, + changeValue: &[]string{ + "val1", + "val2", + "val3", + }, + 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) + + ~ list_block { # forces replacement + ~ prop = "val3" -> "val2" + } + + list_block { # forces replacement + + prop = "val3" + } + + # (1 unchanged block hidden) + } + +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] + ~ listBlocks: [ + ~ [1]: { + ~ prop: "val3" => "val2" + } + + [2]: { + + prop : "val3" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[2]": map[string]interface{}{"kind": "ADD_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_end.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_end.golden new file mode 100644 index 000000000..205bac165 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_end.golden @@ -0,0 +1,62 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "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) + + ~ list_block { # forces replacement + ~ prop = "val1" -> "val2" + } + ~ list_block { # forces replacement + ~ prop = "val2" -> "val1" + } + - list_block { # forces replacement + - prop = "val3" -> 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] + ~ listBlocks: [ + ~ [0]: { + ~ prop: "val1" => "val2" + } + ~ [1]: { + ~ prop: "val2" => "val1" + } + - [2]: { + - prop: "val3" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[2]": map[string]interface{}{"kind": "DELETE_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_front.golden new file mode 100644 index 000000000..9a92bb6cc --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_front.golden @@ -0,0 +1,57 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val3", + "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) + + ~ list_block { # forces replacement + ~ prop = "val1" -> "val3" + } + - list_block { # forces replacement + - prop = "val3" -> null + } + + # (1 unchanged block hidden) + } + +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] + ~ listBlocks: [ + ~ [0]: { + ~ prop: "val1" => "val3" + } + - [2]: { + - prop: "val3" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[2]": map[string]interface{}{"kind": "DELETE_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_middle.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_middle.golden new file mode 100644 index 000000000..fe9e940b6 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/list_element_removed_middle.golden @@ -0,0 +1,62 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val3", + "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) + + ~ list_block { # forces replacement + ~ prop = "val1" -> "val3" + } + ~ list_block { # forces replacement + ~ prop = "val2" -> "val1" + } + - list_block { # forces replacement + - prop = "val3" -> 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] + ~ listBlocks: [ + ~ [0]: { + ~ prop: "val1" => "val3" + } + ~ [1]: { + ~ prop: "val2" => "val1" + } + - [2]: { + - prop: "val3" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[2]": map[string]interface{}{"kind": "DELETE_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/removed_empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/removed_empty.golden new file mode 100644 index 000000000..7bae19762 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/removed_empty.golden @@ -0,0 +1,15 @@ +tests.testOutput{ + initialValue: &[]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/testdata/TestDetailedDiffList/list_block_force_new/removed_non-empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/removed_non-empty.golden new file mode 100644 index 000000000..9379b5e65 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/removed_non-empty.golden @@ -0,0 +1,40 @@ +tests.testOutput{ + initialValue: &[]string{ + "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) + + - list_block { # forces replacement + - prop = "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] + - listBlocks: [ + - [0]: { + - prop: "val1" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listBlocks": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/unchanged_empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/unchanged_empty.golden new file mode 100644 index 000000000..a53fac34d --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/unchanged_empty.golden @@ -0,0 +1,11 @@ +tests.testOutput{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/testdata/TestDetailedDiffList/list_block_force_new/unchanged_non-empty.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/unchanged_non-empty.golden new file mode 100644 index 000000000..e250a9f9c --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + }, + changeValue: &[]string{"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/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/added_empty.golden b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/added_empty.golden new file mode 100644 index 000000000..9589fbdf0 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/added_empty.golden @@ -0,0 +1,15 @@ +tests.testOutput{ + changeValue: &[]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/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/added_non-empty.golden b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/added_non-empty.golden new file mode 100644 index 000000000..86534e8c0 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/added_non-empty.golden @@ -0,0 +1,35 @@ +tests.testOutput{ + changeValue: &[]string{ + "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) + + list_attr = [ # forces replacement + + "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] + + listAttr: "val1" +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttr": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/changed.golden b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/changed.golden new file mode 100644 index 000000000..67bd378f9 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/changed.golden @@ -0,0 +1,36 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + }, + changeValue: &[]string{"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) + ~ list_attr = [ # forces replacement + ~ "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] + ~ listAttr: "val1" => "val2" +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttr": map[string]interface{}{"kind": "UPDATE_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/removed_empty.golden b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/removed_empty.golden new file mode 100644 index 000000000..7bae19762 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/removed_empty.golden @@ -0,0 +1,15 @@ +tests.testOutput{ + initialValue: &[]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/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/removed_non-empty.golden b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/removed_non-empty.golden new file mode 100644 index 000000000..3db772324 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/removed_non-empty.golden @@ -0,0 +1,35 @@ +tests.testOutput{ + initialValue: &[]string{ + "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) + - list_attr = [ # forces replacement + - "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] + - listAttr: "val1" +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttr": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/unchanged_empty.golden b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/unchanged_empty.golden new file mode 100644 index 000000000..a53fac34d --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/unchanged_empty.golden @@ -0,0 +1,11 @@ +tests.testOutput{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/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/unchanged_non-empty.golden b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/unchanged_non-empty.golden new file mode 100644 index 000000000..e250a9f9c --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/max_items_one_attribute_force_new/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + }, + changeValue: &[]string{"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 +`, +}