diff --git a/pkg/tests/detailed_diff_list_test.go b/pkg/tests/detailed_diff_list_test.go index 166a9ad70..ded726a67 100644 --- a/pkg/tests/detailed_diff_list_test.go +++ b/pkg/tests/detailed_diff_list_test.go @@ -1,6 +1,7 @@ package tests import ( + "fmt" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -269,6 +270,14 @@ func TestDetailedDiffList(t *testing.T) { {"changed", ref([]string{"val1"}), ref([]string{"val2"})}, } + longList := &[]string{} + for i := 0; i < 20; i++ { + *longList = append(*longList, fmt.Sprintf("value%d", i)) + } + longListAddedBack := append([]string{}, *longList...) + longListAddedBack = append(longListAddedBack, "value20") + longListAddedFront := append([]string{"value20"}, *longList...) + multiElementScenarios := []struct { name string initialValue *[]string @@ -280,6 +289,12 @@ func TestDetailedDiffList(t *testing.T) { {"list element removed front", ref([]string{"val1", "val2", "val3"}), ref([]string{"val3", "val2"})}, {"list element removed middle", ref([]string{"val1", "val2", "val3"}), ref([]string{"val3", "val1"})}, {"list element removed end", ref([]string{"val1", "val2", "val3"}), ref([]string{"val2", "val1"})}, + {"one added, one removed", ref([]string{"val1", "val2", "val3"}), ref([]string{"val2", "val3", "val4"})}, + {"long list added back", longList, &longListAddedBack}, + // TODO[pulumi/pulumi-terraform-bridge#2239]: These cases present as multiple changes instead of just one + {"long list added front", longList, &longListAddedFront}, + {"long list removed front", &longListAddedFront, longList}, + {"long list removed back", &longListAddedBack, longList}, } scenarios := append(oneElementScenarios, multiElementScenarios...) diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_added_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_added_back.golden new file mode 100644 index 000000000..e37dc03de --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_added_back.golden @@ -0,0 +1,81 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + "value20", + }, + 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_attr = [ + # (19 unchanged elements hidden) + "value19", + + "value20", + ] + } + +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] + ~ listAttrs: [ + + [20]: "value20" + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttrs[20]": map[string]interface{}{}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_added_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_added_front.golden new file mode 100644 index 000000000..ae61d269a --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_added_front.golden @@ -0,0 +1,123 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value20", + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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_attr = [ + + "value20", + "value0", + # (19 unchanged elements hidden) + ] + } + +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] + ~ listAttrs: [ + ~ [0]: "value0" => "value20" + ~ [1]: "value1" => "value0" + ~ [2]: "value2" => "value1" + ~ [3]: "value3" => "value2" + ~ [4]: "value4" => "value3" + ~ [5]: "value5" => "value4" + ~ [6]: "value6" => "value5" + ~ [7]: "value7" => "value6" + ~ [8]: "value8" => "value7" + ~ [9]: "value9" => "value8" + ~ [10]: "value10" => "value9" + ~ [11]: "value11" => "value10" + ~ [12]: "value12" => "value11" + ~ [13]: "value13" => "value12" + ~ [14]: "value14" => "value13" + ~ [15]: "value15" => "value14" + ~ [16]: "value16" => "value15" + ~ [17]: "value17" => "value16" + ~ [18]: "value18" => "value17" + ~ [19]: "value19" => "value18" + + [20]: "value19" + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[0]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[10]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[11]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[12]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[13]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[14]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[15]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[16]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[17]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[18]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[19]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[1]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[20]": map[string]interface{}{}, + "listAttrs[2]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[3]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[4]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[5]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[6]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[7]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[8]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[9]": map[string]interface{}{"kind": "UPDATE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_removed_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_removed_back.golden new file mode 100644 index 000000000..13c73f95c --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_removed_back.golden @@ -0,0 +1,81 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + "value20", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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_attr = [ + # (19 unchanged elements hidden) + "value19", + - "value20", + ] + } + +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] + ~ listAttrs: [ + - [20]: "value20" + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttrs[20]": map[string]interface{}{"kind": "DELETE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_removed_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_removed_front.golden new file mode 100644 index 000000000..79381a7c3 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/long_list_removed_front.golden @@ -0,0 +1,123 @@ +tests.testOutput{ + initialValue: &[]string{ + "value20", + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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_attr = [ + - "value20", + "value0", + # (19 unchanged elements hidden) + ] + } + +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] + ~ listAttrs: [ + ~ [0]: "value20" => "value0" + ~ [1]: "value0" => "value1" + ~ [2]: "value1" => "value2" + ~ [3]: "value2" => "value3" + ~ [4]: "value3" => "value4" + ~ [5]: "value4" => "value5" + ~ [6]: "value5" => "value6" + ~ [7]: "value6" => "value7" + ~ [8]: "value7" => "value8" + ~ [9]: "value8" => "value9" + ~ [10]: "value9" => "value10" + ~ [11]: "value10" => "value11" + ~ [12]: "value11" => "value12" + ~ [13]: "value12" => "value13" + ~ [14]: "value13" => "value14" + ~ [15]: "value14" => "value15" + ~ [16]: "value15" => "value16" + ~ [17]: "value16" => "value17" + ~ [18]: "value17" => "value18" + ~ [19]: "value18" => "value19" + - [20]: "value19" + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[0]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[10]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[11]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[12]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[13]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[14]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[15]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[16]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[17]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[18]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[19]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[1]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[20]": map[string]interface{}{"kind": "DELETE"}, + "listAttrs[2]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[3]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[4]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[5]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[6]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[7]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[8]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[9]": map[string]interface{}{"kind": "UPDATE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute/one_added,_one_removed.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/one_added,_one_removed.golden new file mode 100644 index 000000000..088ca9367 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute/one_added,_one_removed.golden @@ -0,0 +1,52 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "val3", + "val4", + }, + 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_attr = [ + ~ "val1" -> "val2", + ~ "val2" -> "val3", + ~ "val3" -> "val4", + ] + } + +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] + ~ listAttrs: [ + ~ [0]: "val1" => "val2" + ~ [1]: "val2" => "val3" + ~ [2]: "val3" => "val4" + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[0]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[1]": map[string]interface{}{"kind": "UPDATE"}, + "listAttrs[2]": map[string]interface{}{"kind": "UPDATE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_added_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_added_back.golden new file mode 100644 index 000000000..429c0fe1b --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_added_back.golden @@ -0,0 +1,81 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + "value20", + }, + 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 + # (19 unchanged elements hidden) + "value19", + + "value20", + ] + } + +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: [ + + [20]: "value20" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttrs[20]": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_added_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_added_front.golden new file mode 100644 index 000000000..2540d59c1 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_added_front.golden @@ -0,0 +1,123 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value20", + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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 + + "value20", + "value0", + # (19 unchanged elements 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]: "value0" => "value20" + ~ [1]: "value1" => "value0" + ~ [2]: "value2" => "value1" + ~ [3]: "value3" => "value2" + ~ [4]: "value4" => "value3" + ~ [5]: "value5" => "value4" + ~ [6]: "value6" => "value5" + ~ [7]: "value7" => "value6" + ~ [8]: "value8" => "value7" + ~ [9]: "value9" => "value8" + ~ [10]: "value10" => "value9" + ~ [11]: "value11" => "value10" + ~ [12]: "value12" => "value11" + ~ [13]: "value13" => "value12" + ~ [14]: "value14" => "value13" + ~ [15]: "value15" => "value14" + ~ [16]: "value16" => "value15" + ~ [17]: "value17" => "value16" + ~ [18]: "value18" => "value17" + ~ [19]: "value19" => "value18" + + [20]: "value19" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[0]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[10]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[11]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[12]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[13]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[14]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[15]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[16]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[17]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[18]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[19]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[1]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[20]": map[string]interface{}{"kind": "ADD_REPLACE"}, + "listAttrs[2]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[3]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[4]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[5]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[6]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[7]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[8]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[9]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_removed_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_removed_back.golden new file mode 100644 index 000000000..a1a2b2405 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_removed_back.golden @@ -0,0 +1,81 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + "value20", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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 + # (19 unchanged elements hidden) + "value19", + - "value20", + ] + } + +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: [ + - [20]: "value20" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listAttrs[20]": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_removed_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_removed_front.golden new file mode 100644 index 000000000..026739cee --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/long_list_removed_front.golden @@ -0,0 +1,123 @@ +tests.testOutput{ + initialValue: &[]string{ + "value20", + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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 + - "value20", + "value0", + # (19 unchanged elements 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]: "value20" => "value0" + ~ [1]: "value0" => "value1" + ~ [2]: "value1" => "value2" + ~ [3]: "value2" => "value3" + ~ [4]: "value3" => "value4" + ~ [5]: "value4" => "value5" + ~ [6]: "value5" => "value6" + ~ [7]: "value6" => "value7" + ~ [8]: "value7" => "value8" + ~ [9]: "value8" => "value9" + ~ [10]: "value9" => "value10" + ~ [11]: "value10" => "value11" + ~ [12]: "value11" => "value12" + ~ [13]: "value12" => "value13" + ~ [14]: "value13" => "value14" + ~ [15]: "value14" => "value15" + ~ [16]: "value15" => "value16" + ~ [17]: "value16" => "value17" + ~ [18]: "value17" => "value18" + ~ [19]: "value18" => "value19" + - [20]: "value19" + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listAttrs[0]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[10]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[11]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[12]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[13]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[14]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[15]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[16]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[17]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[18]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[19]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[1]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[20]": map[string]interface{}{"kind": "DELETE_REPLACE"}, + "listAttrs[2]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[3]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[4]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[5]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[6]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[7]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[8]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + "listAttrs[9]": map[string]interface{}{"kind": "UPDATE_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/one_added,_one_removed.golden b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/one_added,_one_removed.golden new file mode 100644 index 000000000..631a0ebb0 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_attribute_force_new/one_added,_one_removed.golden @@ -0,0 +1,52 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "val3", + "val4", + }, + 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", + ~ "val2" -> "val3", + ~ "val3" -> "val4", + ] + } + +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" => "val3" + ~ [2]: "val3" => "val4" + ] +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": "UPDATE_REPLACE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_added_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_added_back.golden new file mode 100644 index 000000000..90b2551c9 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_added_back.golden @@ -0,0 +1,84 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + "value20", + }, + 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 = "value20" + } + + # (20 unchanged blocks hidden) + } + +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: [ + + [20]: { + + prop : "value20" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listBlocks[20]": map[string]interface{}{}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_added_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_added_front.golden new file mode 100644 index 000000000..5ce2bf111 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_added_front.golden @@ -0,0 +1,224 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value20", + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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 = "value0" -> "value20" + } + ~ list_block { + ~ prop = "value1" -> "value0" + } + ~ list_block { + ~ prop = "value2" -> "value1" + } + ~ list_block { + ~ prop = "value3" -> "value2" + } + ~ list_block { + ~ prop = "value4" -> "value3" + } + ~ list_block { + ~ prop = "value5" -> "value4" + } + ~ list_block { + ~ prop = "value6" -> "value5" + } + ~ list_block { + ~ prop = "value7" -> "value6" + } + ~ list_block { + ~ prop = "value8" -> "value7" + } + ~ list_block { + ~ prop = "value9" -> "value8" + } + ~ list_block { + ~ prop = "value10" -> "value9" + } + ~ list_block { + ~ prop = "value11" -> "value10" + } + ~ list_block { + ~ prop = "value12" -> "value11" + } + ~ list_block { + ~ prop = "value13" -> "value12" + } + ~ list_block { + ~ prop = "value14" -> "value13" + } + ~ list_block { + ~ prop = "value15" -> "value14" + } + ~ list_block { + ~ prop = "value16" -> "value15" + } + ~ list_block { + ~ prop = "value17" -> "value16" + } + ~ list_block { + ~ prop = "value18" -> "value17" + } + ~ list_block { + ~ prop = "value19" -> "value18" + } + + list_block { + + prop = "value19" + } + } + +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: "value0" => "value20" + } + ~ [1]: { + ~ prop: "value1" => "value0" + } + ~ [2]: { + ~ prop: "value2" => "value1" + } + ~ [3]: { + ~ prop: "value3" => "value2" + } + ~ [4]: { + ~ prop: "value4" => "value3" + } + ~ [5]: { + ~ prop: "value5" => "value4" + } + ~ [6]: { + ~ prop: "value6" => "value5" + } + ~ [7]: { + ~ prop: "value7" => "value6" + } + ~ [8]: { + ~ prop: "value8" => "value7" + } + ~ [9]: { + ~ prop: "value9" => "value8" + } + ~ [10]: { + ~ prop: "value10" => "value9" + } + ~ [11]: { + ~ prop: "value11" => "value10" + } + ~ [12]: { + ~ prop: "value12" => "value11" + } + ~ [13]: { + ~ prop: "value13" => "value12" + } + ~ [14]: { + ~ prop: "value14" => "value13" + } + ~ [15]: { + ~ prop: "value15" => "value14" + } + ~ [16]: { + ~ prop: "value16" => "value15" + } + ~ [17]: { + ~ prop: "value17" => "value16" + } + ~ [18]: { + ~ prop: "value18" => "value17" + } + ~ [19]: { + ~ prop: "value19" => "value18" + } + + [20]: { + + prop : "value19" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[10].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[11].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[12].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[13].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[14].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[15].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[16].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[17].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[18].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[19].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[20]": map[string]interface{}{}, + "listBlocks[2].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[3].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[4].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[5].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[6].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[7].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[8].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[9].prop": map[string]interface{}{"kind": "UPDATE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_removed_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_removed_back.golden new file mode 100644 index 000000000..113f594bf --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_removed_back.golden @@ -0,0 +1,84 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + "value20", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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 = "value20" -> null + } + + # (20 unchanged blocks hidden) + } + +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: [ + - [20]: { + - prop: "value20" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listBlocks[20]": map[string]interface{}{"kind": "DELETE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_removed_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_removed_front.golden new file mode 100644 index 000000000..86111f4fb --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block/long_list_removed_front.golden @@ -0,0 +1,224 @@ +tests.testOutput{ + initialValue: &[]string{ + "value20", + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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 = "value20" -> "value0" + } + ~ list_block { + ~ prop = "value0" -> "value1" + } + ~ list_block { + ~ prop = "value1" -> "value2" + } + ~ list_block { + ~ prop = "value2" -> "value3" + } + ~ list_block { + ~ prop = "value3" -> "value4" + } + ~ list_block { + ~ prop = "value4" -> "value5" + } + ~ list_block { + ~ prop = "value5" -> "value6" + } + ~ list_block { + ~ prop = "value6" -> "value7" + } + ~ list_block { + ~ prop = "value7" -> "value8" + } + ~ list_block { + ~ prop = "value8" -> "value9" + } + ~ list_block { + ~ prop = "value9" -> "value10" + } + ~ list_block { + ~ prop = "value10" -> "value11" + } + ~ list_block { + ~ prop = "value11" -> "value12" + } + ~ list_block { + ~ prop = "value12" -> "value13" + } + ~ list_block { + ~ prop = "value13" -> "value14" + } + ~ list_block { + ~ prop = "value14" -> "value15" + } + ~ list_block { + ~ prop = "value15" -> "value16" + } + ~ list_block { + ~ prop = "value16" -> "value17" + } + ~ list_block { + ~ prop = "value17" -> "value18" + } + ~ list_block { + ~ prop = "value18" -> "value19" + } + - list_block { + - prop = "value19" -> 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] + ~ listBlocks: [ + ~ [0]: { + ~ prop: "value20" => "value0" + } + ~ [1]: { + ~ prop: "value0" => "value1" + } + ~ [2]: { + ~ prop: "value1" => "value2" + } + ~ [3]: { + ~ prop: "value2" => "value3" + } + ~ [4]: { + ~ prop: "value3" => "value4" + } + ~ [5]: { + ~ prop: "value4" => "value5" + } + ~ [6]: { + ~ prop: "value5" => "value6" + } + ~ [7]: { + ~ prop: "value6" => "value7" + } + ~ [8]: { + ~ prop: "value7" => "value8" + } + ~ [9]: { + ~ prop: "value8" => "value9" + } + ~ [10]: { + ~ prop: "value9" => "value10" + } + ~ [11]: { + ~ prop: "value10" => "value11" + } + ~ [12]: { + ~ prop: "value11" => "value12" + } + ~ [13]: { + ~ prop: "value12" => "value13" + } + ~ [14]: { + ~ prop: "value13" => "value14" + } + ~ [15]: { + ~ prop: "value14" => "value15" + } + ~ [16]: { + ~ prop: "value15" => "value16" + } + ~ [17]: { + ~ prop: "value16" => "value17" + } + ~ [18]: { + ~ prop: "value17" => "value18" + } + ~ [19]: { + ~ prop: "value18" => "value19" + } + - [20]: { + - prop: "value19" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[10].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[11].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[12].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[13].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[14].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[15].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[16].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[17].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[18].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[19].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[20]": map[string]interface{}{"kind": "DELETE"}, + "listBlocks[2].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[3].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[4].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[5].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[6].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[7].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[8].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[9].prop": map[string]interface{}{"kind": "UPDATE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block/one_added,_one_removed.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block/one_added,_one_removed.golden new file mode 100644 index 000000000..5658a65a0 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block/one_added,_one_removed.golden @@ -0,0 +1,63 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "val3", + "val4", + }, + 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" + } + ~ list_block { + ~ prop = "val2" -> "val3" + } + ~ list_block { + ~ prop = "val3" -> "val4" + } + } + +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" + } + ~ [1]: { + ~ prop: "val2" => "val3" + } + ~ [2]: { + ~ prop: "val3" => "val4" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[2].prop": map[string]interface{}{"kind": "UPDATE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_added_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_added_back.golden new file mode 100644 index 000000000..f5a98ba62 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_added_back.golden @@ -0,0 +1,84 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + "value20", + }, + 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 = "value20" + } + + # (20 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: [ + + [20]: { + + prop : "value20" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listBlocks[20]": map[string]interface{}{"kind": "ADD_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_added_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_added_front.golden new file mode 100644 index 000000000..ce1f68dc3 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_added_front.golden @@ -0,0 +1,224 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value20", + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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 = "value0" -> "value20" + } + ~ list_block { # forces replacement + ~ prop = "value1" -> "value0" + } + ~ list_block { # forces replacement + ~ prop = "value2" -> "value1" + } + ~ list_block { # forces replacement + ~ prop = "value3" -> "value2" + } + ~ list_block { # forces replacement + ~ prop = "value4" -> "value3" + } + ~ list_block { # forces replacement + ~ prop = "value5" -> "value4" + } + ~ list_block { # forces replacement + ~ prop = "value6" -> "value5" + } + ~ list_block { # forces replacement + ~ prop = "value7" -> "value6" + } + ~ list_block { # forces replacement + ~ prop = "value8" -> "value7" + } + ~ list_block { # forces replacement + ~ prop = "value9" -> "value8" + } + ~ list_block { # forces replacement + ~ prop = "value10" -> "value9" + } + ~ list_block { # forces replacement + ~ prop = "value11" -> "value10" + } + ~ list_block { # forces replacement + ~ prop = "value12" -> "value11" + } + ~ list_block { # forces replacement + ~ prop = "value13" -> "value12" + } + ~ list_block { # forces replacement + ~ prop = "value14" -> "value13" + } + ~ list_block { # forces replacement + ~ prop = "value15" -> "value14" + } + ~ list_block { # forces replacement + ~ prop = "value16" -> "value15" + } + ~ list_block { # forces replacement + ~ prop = "value17" -> "value16" + } + ~ list_block { # forces replacement + ~ prop = "value18" -> "value17" + } + ~ list_block { # forces replacement + ~ prop = "value19" -> "value18" + } + + list_block { # forces replacement + + prop = "value19" + } + } + +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: "value0" => "value20" + } + ~ [1]: { + ~ prop: "value1" => "value0" + } + ~ [2]: { + ~ prop: "value2" => "value1" + } + ~ [3]: { + ~ prop: "value3" => "value2" + } + ~ [4]: { + ~ prop: "value4" => "value3" + } + ~ [5]: { + ~ prop: "value5" => "value4" + } + ~ [6]: { + ~ prop: "value6" => "value5" + } + ~ [7]: { + ~ prop: "value7" => "value6" + } + ~ [8]: { + ~ prop: "value8" => "value7" + } + ~ [9]: { + ~ prop: "value9" => "value8" + } + ~ [10]: { + ~ prop: "value10" => "value9" + } + ~ [11]: { + ~ prop: "value11" => "value10" + } + ~ [12]: { + ~ prop: "value12" => "value11" + } + ~ [13]: { + ~ prop: "value13" => "value12" + } + ~ [14]: { + ~ prop: "value14" => "value13" + } + ~ [15]: { + ~ prop: "value15" => "value14" + } + ~ [16]: { + ~ prop: "value16" => "value15" + } + ~ [17]: { + ~ prop: "value17" => "value16" + } + ~ [18]: { + ~ prop: "value18" => "value17" + } + ~ [19]: { + ~ prop: "value19" => "value18" + } + + [20]: { + + prop : "value19" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[10].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[11].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[12].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[13].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[14].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[15].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[16].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[17].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[18].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[19].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[20]": map[string]interface{}{"kind": "ADD_REPLACE"}, + "listBlocks[2].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[3].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[4].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[5].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[6].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[7].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[8].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[9].prop": map[string]interface{}{"kind": "UPDATE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_removed_back.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_removed_back.golden new file mode 100644 index 000000000..4117bc078 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_removed_back.golden @@ -0,0 +1,84 @@ +tests.testOutput{ + initialValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + "value20", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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 = "value20" -> null + } + + # (20 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: [ + - [20]: { + - prop: "value20" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{"listBlocks[20]": map[string]interface{}{"kind": "DELETE_REPLACE"}}, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_removed_front.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_removed_front.golden new file mode 100644 index 000000000..e13e11347 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/long_list_removed_front.golden @@ -0,0 +1,224 @@ +tests.testOutput{ + initialValue: &[]string{ + "value20", + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + changeValue: &[]string{ + "value0", + "value1", + "value2", + "value3", + "value4", + "value5", + "value6", + "value7", + "value8", + "value9", + "value10", + "value11", + "value12", + "value13", + "value14", + "value15", + "value16", + "value17", + "value18", + "value19", + }, + 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 = "value20" -> "value0" + } + ~ list_block { # forces replacement + ~ prop = "value0" -> "value1" + } + ~ list_block { # forces replacement + ~ prop = "value1" -> "value2" + } + ~ list_block { # forces replacement + ~ prop = "value2" -> "value3" + } + ~ list_block { # forces replacement + ~ prop = "value3" -> "value4" + } + ~ list_block { # forces replacement + ~ prop = "value4" -> "value5" + } + ~ list_block { # forces replacement + ~ prop = "value5" -> "value6" + } + ~ list_block { # forces replacement + ~ prop = "value6" -> "value7" + } + ~ list_block { # forces replacement + ~ prop = "value7" -> "value8" + } + ~ list_block { # forces replacement + ~ prop = "value8" -> "value9" + } + ~ list_block { # forces replacement + ~ prop = "value9" -> "value10" + } + ~ list_block { # forces replacement + ~ prop = "value10" -> "value11" + } + ~ list_block { # forces replacement + ~ prop = "value11" -> "value12" + } + ~ list_block { # forces replacement + ~ prop = "value12" -> "value13" + } + ~ list_block { # forces replacement + ~ prop = "value13" -> "value14" + } + ~ list_block { # forces replacement + ~ prop = "value14" -> "value15" + } + ~ list_block { # forces replacement + ~ prop = "value15" -> "value16" + } + ~ list_block { # forces replacement + ~ prop = "value16" -> "value17" + } + ~ list_block { # forces replacement + ~ prop = "value17" -> "value18" + } + ~ list_block { # forces replacement + ~ prop = "value18" -> "value19" + } + - list_block { # forces replacement + - prop = "value19" -> 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: "value20" => "value0" + } + ~ [1]: { + ~ prop: "value0" => "value1" + } + ~ [2]: { + ~ prop: "value1" => "value2" + } + ~ [3]: { + ~ prop: "value2" => "value3" + } + ~ [4]: { + ~ prop: "value3" => "value4" + } + ~ [5]: { + ~ prop: "value4" => "value5" + } + ~ [6]: { + ~ prop: "value5" => "value6" + } + ~ [7]: { + ~ prop: "value6" => "value7" + } + ~ [8]: { + ~ prop: "value7" => "value8" + } + ~ [9]: { + ~ prop: "value8" => "value9" + } + ~ [10]: { + ~ prop: "value9" => "value10" + } + ~ [11]: { + ~ prop: "value10" => "value11" + } + ~ [12]: { + ~ prop: "value11" => "value12" + } + ~ [13]: { + ~ prop: "value12" => "value13" + } + ~ [14]: { + ~ prop: "value13" => "value14" + } + ~ [15]: { + ~ prop: "value14" => "value15" + } + ~ [16]: { + ~ prop: "value15" => "value16" + } + ~ [17]: { + ~ prop: "value16" => "value17" + } + ~ [18]: { + ~ prop: "value17" => "value18" + } + ~ [19]: { + ~ prop: "value18" => "value19" + } + - [20]: { + - prop: "value19" + } + ] +Resources: + +-1 to replace + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[10].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[11].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[12].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[13].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[14].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[15].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[16].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[17].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[18].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[19].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[20]": map[string]interface{}{"kind": "DELETE_REPLACE"}, + "listBlocks[2].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[3].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[4].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[5].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[6].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[7].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[8].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[9].prop": map[string]interface{}{"kind": "UPDATE"}, + }, +} diff --git a/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/one_added,_one_removed.golden b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/one_added,_one_removed.golden new file mode 100644 index 000000000..5658a65a0 --- /dev/null +++ b/pkg/tests/testdata/TestDetailedDiffList/list_block_force_new/one_added,_one_removed.golden @@ -0,0 +1,63 @@ +tests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "val3", + "val4", + }, + 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" + } + ~ list_block { + ~ prop = "val2" -> "val3" + } + ~ list_block { + ~ prop = "val3" -> "val4" + } + } + +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" + } + ~ [1]: { + ~ prop: "val2" => "val3" + } + ~ [2]: { + ~ prop: "val3" => "val4" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, + detailedDiff: map[string]interface{}{ + "listBlocks[0].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[1].prop": map[string]interface{}{"kind": "UPDATE"}, + "listBlocks[2].prop": map[string]interface{}{"kind": "UPDATE"}, + }, +}