diff --git a/pkg/pf/tests/diff_set_test.go b/pkg/pf/tests/diff_set_test.go index c28511491..7a4664949 100644 --- a/pkg/pf/tests/diff_set_test.go +++ b/pkg/pf/tests/diff_set_test.go @@ -7,10 +7,12 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/defaults" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hexops/autogold/v2" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" "github.com/zclconf/go-cty/cty" @@ -19,6 +21,24 @@ import ( pb "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tests/internal/providerbuilder" ) +type setDefault string + +var _ defaults.Set = setDefault("default") + +func (s setDefault) DefaultSet(ctx context.Context, req defaults.SetRequest, resp *defaults.SetResponse) { + resp.PlanValue = basetypes.NewSetValueMust(types.StringType, []attr.Value{ + basetypes.NewStringValue("value"), + }) +} + +func (s setDefault) Description(ctx context.Context) string { + return "description" +} + +func (s setDefault) MarkdownDescription(ctx context.Context) string { + return "markdown description" +} + func TestDetailedDiffSet(t *testing.T) { t.Parallel() @@ -33,6 +53,22 @@ func TestDetailedDiffSet(t *testing.T) { }, }) + attributeSchemaWithDefault := pb.NewResource(pb.NewResourceArgs{ + ResourceSchema: rschema.Schema{ + Attributes: map[string]rschema.Attribute{ + "key": rschema.SetAttribute{ + Optional: true, + Computed: true, + ElementType: types.StringType, + Default: setDefault("default"), + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + }, + }, + }, + }) + attributeReplaceSchema := pb.NewResource(pb.NewResourceArgs{ ResourceSchema: rschema.Schema{ Attributes: map[string]rschema.Attribute{ @@ -114,6 +150,27 @@ func TestDetailedDiffSet(t *testing.T) { }, }) + blockSchemaWithDefault := pb.NewResource(pb.NewResourceArgs{ + ResourceSchema: rschema.Schema{ + Blocks: map[string]rschema.Block{ + "key": rschema.SetNestedBlock{ + NestedObject: rschema.NestedBlockObject{ + Attributes: map[string]rschema.Attribute{ + "nested": rschema.StringAttribute{ + Optional: true, + Default: stringDefault("default"), + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + }, + }, + }, + }, + }, + }) + blockReplaceSchema := pb.NewResource(pb.NewResourceArgs{ ResourceSchema: rschema.Schema{ Blocks: map[string]rschema.Block{ @@ -467,6 +524,10 @@ func TestDetailedDiffSet(t *testing.T) { {"block requires replace", blockReplaceSchema, nestedAttrList}, {"block nested requires replace", blockNestedReplaceSchema, nestedAttrList}, + // Defaults + {"attribute with default", attributeSchemaWithDefault, attrList}, + {"block with default", blockSchemaWithDefault, nestedAttrList}, + // Computed attributes {"attribute with computed no replace", computedSetAttributeSchema, attrList}, {"attribute with computed requires replace", computedSetAttributeReplaceSchema, attrList}, diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added.golden new file mode 100644 index 000000000..080a4f237 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added.golden @@ -0,0 +1,35 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{}, + changeValue: &[]string{"value"}, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + + "value", + ] + } + +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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + + [0]: "value" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_end.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_end.golden new file mode 100644 index 000000000..7ccf6fab5 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_end.golden @@ -0,0 +1,45 @@ +tfbridgetests.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: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + + "val3", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: "val1" + [1]: "val2" + + [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_end_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_end_unordered.golden new file mode 100644 index 000000000..906c8d3fb --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_end_unordered.golden @@ -0,0 +1,45 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + + "val1", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: "val2" + [1]: "val3" + + [2]: "val1" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_front.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_front.golden new file mode 100644 index 000000000..470c6dfc5 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_front.golden @@ -0,0 +1,45 @@ +tfbridgetests.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: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + + "val1", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: "val2" => "val1" + ~ [1]: "val3" => "val2" + + [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_front_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_front_unordered.golden new file mode 100644 index 000000000..81a40f49c --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_front_unordered.golden @@ -0,0 +1,45 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val3", + "val1", + }, + changeValue: &[]string{ + "val2", + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + + "val2", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: "val3" => "val2" + ~ [1]: "val1" => "val3" + + [2]: "val1" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_middle.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_middle.golden new file mode 100644 index 000000000..5420a4f62 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_middle.golden @@ -0,0 +1,45 @@ +tfbridgetests.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: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + + "val2", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: "val1" + ~ [1]: "val3" => "val2" + + [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_middle_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_middle_unordered.golden new file mode 100644 index 000000000..f714d3971 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/added_middle_unordered.golden @@ -0,0 +1,45 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val1", + }, + changeValue: &[]string{ + "val2", + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + + "val3", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: "val2" + ~ [1]: "val1" => "val3" + + [2]: "val1" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_empty_to_null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_empty_to_null.golden new file mode 100644 index 000000000..d4029d981 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_empty_to_null.golden @@ -0,0 +1,32 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + + "value", + ] + } + +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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + - keys: [] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_non-null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_non-null.golden new file mode 100644 index 000000000..69e027b27 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_non-null.golden @@ -0,0 +1,38 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "value", + }, + changeValue: &[]string{"value1"}, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + - "value", + + "value1", + ] + } + +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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: "value" => "value1" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_non-null_to_null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_non-null_to_null.golden new file mode 100644 index 000000000..74022ca51 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_non-null_to_null.golden @@ -0,0 +1,17 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "value", + }, + 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/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_null_to_empty.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_null_to_empty.golden new file mode 100644 index 000000000..d4baaf763 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_null_to_empty.golden @@ -0,0 +1,32 @@ +tfbridgetests.testOutput{ + changeValue: &[]string{}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + - "value", + ] + } + +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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + + keys: [] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_null_to_non-null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_null_to_non-null.golden new file mode 100644 index 000000000..28bf51453 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/changed_null_to_non-null.golden @@ -0,0 +1,17 @@ +tfbridgetests.testOutput{ + changeValue: &[]string{ + "value", + }, + 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/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed.golden new file mode 100644 index 000000000..caa6105c4 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed.golden @@ -0,0 +1,37 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "value", + }, + changeValue: &[]string{}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + - "value", + ] + } + +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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + - [0]: "value" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_end.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_end.golden new file mode 100644 index 000000000..d1bb765eb --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_end.golden @@ -0,0 +1,45 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val1", + "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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + - "val3", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: "val1" + [1]: "val2" + - [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_end_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_end_unordered.golden new file mode 100644 index 000000000..a119081b4 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_end_unordered.golden @@ -0,0 +1,45 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + "val1", + }, + changeValue: &[]string{ + "val2", + "val3", + }, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + - "val1", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: "val2" + [1]: "val3" + - [2]: "val1" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_front.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_front.golden new file mode 100644 index 000000000..f669b9535 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_front.golden @@ -0,0 +1,45 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "val3", + }, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + - "val1", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: "val1" => "val2" + ~ [1]: "val2" => "val3" + - [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_front_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_front_unordered.golden new file mode 100644 index 000000000..1572faa4f --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_front_unordered.golden @@ -0,0 +1,45 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + "val1", + }, + changeValue: &[]string{ + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + - "val2", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: "val2" => "val3" + ~ [1]: "val3" => "val1" + - [2]: "val1" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_middle.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_middle.golden new file mode 100644 index 000000000..9c755e00e --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_middle.golden @@ -0,0 +1,45 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val1", + "val3", + }, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + - "val2", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: "val1" + ~ [1]: "val2" => "val3" + - [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_middle_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_middle_unordered.golden new file mode 100644 index 000000000..1913f8822 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/removed_middle_unordered.golden @@ -0,0 +1,45 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val3", + "val1", + "val2", + }, + changeValue: &[]string{ + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + ~ key = [ + - "val2", + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: "val3" + [1]: "val1" + - [2]: "val2" + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/shuffled.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/shuffled.golden new file mode 100644 index 000000000..40cc0f9fc --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/shuffled.golden @@ -0,0 +1,24 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val3", + "val1", + "val2", + }, + 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/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/shuffled_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/shuffled_unordered.golden new file mode 100644 index 000000000..158e21676 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/shuffled_unordered.golden @@ -0,0 +1,24 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + "val1", + }, + changeValue: &[]string{ + "val3", + "val1", + "val2", + }, + 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/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/unchanged_empty.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/unchanged_empty.golden new file mode 100644 index 000000000..0ccb908d5 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/unchanged_empty.golden @@ -0,0 +1,16 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{}, + 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/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/unchanged_non-empty.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/unchanged_non-empty.golden new file mode 100644 index 000000000..ccbeefd86 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "value", + }, + changeValue: &[]string{"value"}, + 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/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/unchanged_null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/unchanged_null.golden new file mode 100644 index 000000000..78b0aa1b3 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/attribute_with_default/unchanged_null.golden @@ -0,0 +1,11 @@ +tfbridgetests.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/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added.golden new file mode 100644 index 000000000..a1a22e6cd --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added.golden @@ -0,0 +1,38 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{}, + changeValue: &[]string{"value"}, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + + key { + + nested = "value" + } + } + +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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + + [0]: { + + nested: "value" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_end.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_end.golden new file mode 100644 index 000000000..cd5a85f19 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_end.golden @@ -0,0 +1,53 @@ +tfbridgetests.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: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + + key { + + nested = "val3" + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: { + nested: "val1" + } + [1]: { + nested: "val2" + } + + [2]: { + + nested: "val3" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_end_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_end_unordered.golden new file mode 100644 index 000000000..c21075962 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_end_unordered.golden @@ -0,0 +1,53 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + + key { + + nested = "val1" + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: { + nested: "val2" + } + [1]: { + nested: "val3" + } + + [2]: { + + nested: "val1" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_front.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_front.golden new file mode 100644 index 000000000..0885bbc4c --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_front.golden @@ -0,0 +1,53 @@ +tfbridgetests.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: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + + key { + + nested = "val1" + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: { + ~ nested: "val2" => "val1" + } + ~ [1]: { + ~ nested: "val3" => "val2" + } + + [2]: { + + nested: "val3" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_front_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_front_unordered.golden new file mode 100644 index 000000000..ad2e67f21 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_front_unordered.golden @@ -0,0 +1,53 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val3", + "val1", + }, + changeValue: &[]string{ + "val2", + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + + key { + + nested = "val2" + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: { + ~ nested: "val3" => "val2" + } + ~ [1]: { + ~ nested: "val1" => "val3" + } + + [2]: { + + nested: "val1" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_middle.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_middle.golden new file mode 100644 index 000000000..0fe0fcba3 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_middle.golden @@ -0,0 +1,53 @@ +tfbridgetests.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: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + + key { + + nested = "val2" + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: { + nested: "val1" + } + ~ [1]: { + ~ nested: "val3" => "val2" + } + + [2]: { + + nested: "val3" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_middle_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_middle_unordered.golden new file mode 100644 index 000000000..f6473df60 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/added_middle_unordered.golden @@ -0,0 +1,53 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val1", + }, + changeValue: &[]string{ + "val2", + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + + key { + + nested = "val3" + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: { + nested: "val2" + } + ~ [1]: { + ~ nested: "val1" => "val3" + } + + [2]: { + + nested: "val1" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_empty_to_null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_empty_to_null.golden new file mode 100644 index 000000000..7fb29dc92 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_empty_to_null.golden @@ -0,0 +1,15 @@ +tfbridgetests.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/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_non-null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_non-null.golden new file mode 100644 index 000000000..90ff7b8ed --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_non-null.golden @@ -0,0 +1,43 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "value", + }, + changeValue: &[]string{"value1"}, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + - key { + - nested = "value" -> null + } + + key { + + nested = "value1" + } + } + +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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: { + ~ nested: "value" => "value1" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_non-null_to_null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_non-null_to_null.golden new file mode 100644 index 000000000..9f47e3a45 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_non-null_to_null.golden @@ -0,0 +1,39 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "value", + }, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + - key { + - nested = "value" -> 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + - keys: [ + - [0]: { + - nested: "value" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_null_to_empty.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_null_to_empty.golden new file mode 100644 index 000000000..9cc2b128c --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_null_to_empty.golden @@ -0,0 +1,15 @@ +tfbridgetests.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/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_null_to_non-null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_null_to_non-null.golden new file mode 100644 index 000000000..e30c0dc9d --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/changed_null_to_non-null.golden @@ -0,0 +1,39 @@ +tfbridgetests.testOutput{ + changeValue: &[]string{ + "value", + }, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + + key { + + nested = "value" + } + } + +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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + + keys: [ + + [0]: { + + nested: "value" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed.golden new file mode 100644 index 000000000..69321472e --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed.golden @@ -0,0 +1,40 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "value", + }, + changeValue: &[]string{}, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + - key { + - nested = "value" -> 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + - [0]: { + - nested: "value" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_end.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_end.golden new file mode 100644 index 000000000..18b194f94 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_end.golden @@ -0,0 +1,53 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val1", + "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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + - key { + - nested = "val3" -> null + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: { + nested: "val1" + } + [1]: { + nested: "val2" + } + - [2]: { + - nested: "val3" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_end_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_end_unordered.golden new file mode 100644 index 000000000..5b3ba35bd --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_end_unordered.golden @@ -0,0 +1,53 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + "val1", + }, + changeValue: &[]string{ + "val2", + "val3", + }, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + - key { + - nested = "val1" -> null + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: { + nested: "val2" + } + [1]: { + nested: "val3" + } + - [2]: { + - nested: "val1" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_front.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_front.golden new file mode 100644 index 000000000..14432c685 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_front.golden @@ -0,0 +1,53 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val2", + "val3", + }, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + - key { + - nested = "val1" -> null + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: { + ~ nested: "val1" => "val2" + } + ~ [1]: { + ~ nested: "val2" => "val3" + } + - [2]: { + - nested: "val3" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_front_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_front_unordered.golden new file mode 100644 index 000000000..5313deb5d --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_front_unordered.golden @@ -0,0 +1,53 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + "val1", + }, + changeValue: &[]string{ + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + - key { + - nested = "val2" -> null + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + ~ [0]: { + ~ nested: "val2" => "val3" + } + ~ [1]: { + ~ nested: "val3" => "val1" + } + - [2]: { + - nested: "val1" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_middle.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_middle.golden new file mode 100644 index 000000000..5d9648920 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_middle.golden @@ -0,0 +1,53 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val1", + "val3", + }, + 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: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + - key { + - nested = "val2" -> null + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: { + nested: "val1" + } + ~ [1]: { + ~ nested: "val2" => "val3" + } + - [2]: { + - nested: "val3" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_middle_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_middle_unordered.golden new file mode 100644 index 000000000..4d07fab0a --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/removed_middle_unordered.golden @@ -0,0 +1,53 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val3", + "val1", + "val2", + }, + changeValue: &[]string{ + "val3", + "val1", + }, + tfOut: ` +Terraform used the selected providers to generate the following execution +plan. Resource actions are indicated with the following symbols: + ~ update in-place + +Terraform will perform the following actions: + + # testprovider_test.res will be updated in-place + ~ resource "testprovider_test" "res" { + id = "test-id" + + - key { + - nested = "val2" -> null + } + + # (2 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] + ~ testprovider:index/test:Test: (update) + [id=test-id] + [urn=urn:pulumi:test::project::testprovider:index/test:Test::p] + ~ keys: [ + [0]: { + nested: "val3" + } + [1]: { + nested: "val1" + } + - [2]: { + - nested: "val2" + } + ] +Resources: + ~ 1 to update + 1 unchanged +`, +} diff --git a/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/shuffled.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/shuffled.golden new file mode 100644 index 000000000..40cc0f9fc --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/shuffled.golden @@ -0,0 +1,24 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val1", + "val2", + "val3", + }, + changeValue: &[]string{ + "val3", + "val1", + "val2", + }, + 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/pf/tests/testdata/TestDetailedDiffSet/block_with_default/shuffled_unordered.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/shuffled_unordered.golden new file mode 100644 index 000000000..158e21676 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/shuffled_unordered.golden @@ -0,0 +1,24 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "val2", + "val3", + "val1", + }, + changeValue: &[]string{ + "val3", + "val1", + "val2", + }, + 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/pf/tests/testdata/TestDetailedDiffSet/block_with_default/unchanged_empty.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/unchanged_empty.golden new file mode 100644 index 000000000..0ccb908d5 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/unchanged_empty.golden @@ -0,0 +1,16 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{}, + 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/pf/tests/testdata/TestDetailedDiffSet/block_with_default/unchanged_non-empty.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/unchanged_non-empty.golden new file mode 100644 index 000000000..ccbeefd86 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/unchanged_non-empty.golden @@ -0,0 +1,18 @@ +tfbridgetests.testOutput{ + initialValue: &[]string{ + "value", + }, + changeValue: &[]string{"value"}, + 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/pf/tests/testdata/TestDetailedDiffSet/block_with_default/unchanged_null.golden b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/unchanged_null.golden new file mode 100644 index 000000000..78b0aa1b3 --- /dev/null +++ b/pkg/pf/tests/testdata/TestDetailedDiffSet/block_with_default/unchanged_null.golden @@ -0,0 +1,11 @@ +tfbridgetests.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 +`}