From 167bf63685d0dd15e7968dbea2ac19856979d75f Mon Sep 17 00:00:00 2001 From: Venelin Date: Wed, 3 Jul 2024 16:18:19 +0100 Subject: [PATCH 1/7] add detailed diff tests for plain types --- pkg/tests/schema_pulumi_test.go | 764 ++++++++++++++++++++++++++++++++ 1 file changed, 764 insertions(+) diff --git a/pkg/tests/schema_pulumi_test.go b/pkg/tests/schema_pulumi_test.go index 3b17a109d..98e574b2d 100644 --- a/pkg/tests/schema_pulumi_test.go +++ b/pkg/tests/schema_pulumi_test.go @@ -2,6 +2,7 @@ package tests import ( "context" + "encoding/json" "fmt" "os" "path/filepath" @@ -1410,3 +1411,766 @@ Resources: }) } } + +func TestDetailedDiffPlainTypes(t *testing.T) { + resMap := map[string]*schema.Resource{ + "prov_test": { + Schema: map[string]*schema.Schema{ + "string_prop": { + Type: schema.TypeString, + Optional: true, + }, + "list_prop": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "set_prop": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "map_prop": { + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + } + bridgedProvider := pulcheck.BridgedProvider(t, "prov", resMap) + + program := ` +name: test +runtime: yaml +resources: + mainRes: + type: prov:index:Test + properties: %s +` + + for _, tc := range []struct { + name string + props1 interface{} + props2 interface{} + expected autogold.Value + }{ + { + "string unchanged", + map[string]interface{}{"stringProp": "val"}, + map[string]interface{}{"stringProp": "val"}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] +Resources: + 2 unchanged +`), + }, + { + "string added", + map[string]interface{}{}, + map[string]interface{}{"stringProp": "val"}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + + stringProp: "val" +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "string removed", + map[string]interface{}{"stringProp": "val1"}, + map[string]interface{}{}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + - stringProp: "val1" +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "string changed", + map[string]interface{}{"stringProp": "val1"}, + map[string]interface{}{"stringProp": "val2"}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ stringProp: "val1" => "val2" +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list unchanged", + map[string]interface{}{"listProps": []interface{}{"val"}}, + map[string]interface{}{"listProps": []interface{}{"val"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] +Resources: + 2 unchanged +`), + }, + { + "list added", + map[string]interface{}{}, + map[string]interface{}{"listProps": []interface{}{"val"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + + listProps: [ + + [0]: "val" + ] + + listProps: [ + + [0]: "val" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list added empty", + map[string]interface{}{}, + map[string]interface{}{"listProps": []interface{}{}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + + listProps: [ + + [0]: "val" + ] + + listProps: [ + + [0]: "val" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list removed", + map[string]interface{}{"listProps": []interface{}{"val"}}, + map[string]interface{}{}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + - listProps: [ + - [0]: "val" + ] + - listProps: [ + - [0]: "val" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list removed empty", + map[string]interface{}{"listProps": []interface{}{}}, + map[string]interface{}{}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + - listProps: [ + - [0]: "val" + ] + - listProps: [ + - [0]: "val" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list element added front", + map[string]interface{}{"listProps": []interface{}{"val2", "val3"}}, + map[string]interface{}{"listProps": []interface{}{"val1", "val2", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ listProps: [ + ~ [0]: "val2" => "val1" + ~ [1]: "val3" => "val2" + + [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list element added back", + map[string]interface{}{"listProps": []interface{}{"val1", "val2"}}, + map[string]interface{}{"listProps": []interface{}{"val1", "val2", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ listProps: [ + [0]: "val1" + [1]: "val2" + + [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list element added middle", + map[string]interface{}{"listProps": []interface{}{"val1", "val3"}}, + map[string]interface{}{"listProps": []interface{}{"val1", "val2", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ listProps: [ + [0]: "val1" + ~ [1]: "val3" => "val2" + + [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list element removed front", + map[string]interface{}{"listProps": []interface{}{"val1", "val2", "val3"}}, + map[string]interface{}{"listProps": []interface{}{"val2", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ listProps: [ + ~ [0]: "val1" => "val2" + ~ [1]: "val2" => "val3" + - [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list element removed back", + map[string]interface{}{"listProps": []interface{}{"val1", "val2", "val3"}}, + map[string]interface{}{"listProps": []interface{}{"val1", "val2"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ listProps: [ + [0]: "val1" + [1]: "val2" + - [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list element removed middle", + map[string]interface{}{"listProps": []interface{}{"val1", "val2", "val3"}}, + map[string]interface{}{"listProps": []interface{}{"val1", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ listProps: [ + [0]: "val1" + ~ [1]: "val2" => "val3" + - [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "list element changed", + map[string]interface{}{"listProps": []interface{}{"val1"}}, + map[string]interface{}{"listProps": []interface{}{"val2"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ listProps: [ + ~ [0]: "val1" => "val2" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set unchanged", + map[string]interface{}{"setProps": []interface{}{"val"}}, + map[string]interface{}{"setProps": []interface{}{"val"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] +Resources: + 2 unchanged +`), + }, + { + "set added", + map[string]interface{}{}, + map[string]interface{}{"setProps": []interface{}{"val"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + + setProps: [ + + [0]: "val" + ] + + setProps: [ + + [0]: "val" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set added empty", + map[string]interface{}{}, + map[string]interface{}{"setProps": []interface{}{}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + + setProps: [ + + [0]: "val" + ] + + setProps: [ + + [0]: "val" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set removed", + map[string]interface{}{"setProps": []interface{}{"val"}}, + map[string]interface{}{}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + - setProps: [ + - [0]: "val" + ] + - setProps: [ + - [0]: "val" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set removed empty", + map[string]interface{}{"setProps": []interface{}{}}, + map[string]interface{}{}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + - setProps: [ + - [0]: "val" + ] + - setProps: [ + - [0]: "val" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set element added front", + map[string]interface{}{"setProps": []interface{}{"val2", "val3"}}, + map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ setProps: [ + ~ [0]: "val2" => "val1" + ~ [1]: "val3" => "val2" + + [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set element added back", + map[string]interface{}{"setProps": []interface{}{"val1", "val2"}}, + map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ setProps: [ + [0]: "val1" + [1]: "val2" + + [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set element added middle", + map[string]interface{}{"setProps": []interface{}{"val1", "val3"}}, + map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ setProps: [ + [0]: "val1" + ~ [1]: "val3" => "val2" + + [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set element removed front", + map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, + map[string]interface{}{"setProps": []interface{}{"val2", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ setProps: [ + ~ [0]: "val1" => "val2" + ~ [1]: "val2" => "val3" + - [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set element removed back", + map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, + map[string]interface{}{"setProps": []interface{}{"val1", "val2"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ setProps: [ + [0]: "val1" + [1]: "val2" + - [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set element removed middle", + map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, + map[string]interface{}{"setProps": []interface{}{"val1", "val3"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ setProps: [ + [0]: "val1" + - [1]: "val2" + - [2]: "val3" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "set element changed", + map[string]interface{}{"setProps": []interface{}{"val1"}}, + map[string]interface{}{"setProps": []interface{}{"val2"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ setProps: [ + ~ [0]: "val1" => "val2" + ] +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "map unchanged", + map[string]interface{}{"mapProp": map[string]interface{}{"key": "val"}}, + map[string]interface{}{"mapProp": map[string]interface{}{"key": "val"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] +Resources: + 2 unchanged +`), + }, + { + "map added", + map[string]interface{}{}, + map[string]interface{}{"mapProp": map[string]interface{}{"key": "val"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + + mapProp: { + + key: "val" + } + + mapProp: { + + key: "val" + } +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "map added empty", + map[string]interface{}{}, + map[string]interface{}{"mapProp": map[string]interface{}{}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + + mapProp: { + + key: "val" + } + + mapProp: { + + key: "val" + } +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "map removed", + map[string]interface{}{"mapProp": map[string]interface{}{"key": "val"}}, + map[string]interface{}{}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + - mapProp: { + - key: "val" + } + - mapProp: { + - key: "val" + } +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "map removed empty", + map[string]interface{}{"mapProp": map[string]interface{}{}}, + map[string]interface{}{}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + - mapProp: { + - key: "val" + } + - mapProp: { + - key: "val" + } +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "map element added", + map[string]interface{}{"mapProp": map[string]interface{}{}}, + map[string]interface{}{"mapProp": map[string]interface{}{"key": "val"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + + mapProp: { + + key: "val" + } + + mapProp: { + + key: "val" + } +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "map element removed", + map[string]interface{}{"mapProp": map[string]interface{}{"key": "val"}}, + map[string]interface{}{"mapProp": map[string]interface{}{}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ mapProp: { + - key: "val" + } +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "map value changed", + map[string]interface{}{"mapProp": map[string]interface{}{"key": "val1"}}, + map[string]interface{}{"mapProp": map[string]interface{}{"key": "val2"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ mapProp: { + ~ key: "val1" => "val2" + } +Resources: + ~ 1 to update + 1 unchanged +`), + }, + { + "map key changed", + map[string]interface{}{"mapProp": map[string]interface{}{"key1": "val"}}, + map[string]interface{}{"mapProp": map[string]interface{}{"key2": "val"}}, + autogold.Expect(`Previewing update (test): + pulumi:pulumi:Stack: (same) + [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + ~ prov:index/test:Test: (update) + [id=newid] + [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + ~ mapProp: { + - key1: "val" + + key2: "val" + } +Resources: + ~ 1 to update + 1 unchanged +`), + }, + } { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + props1, err := json.Marshal(tc.props1) + require.NoError(t, err) + program1 := fmt.Sprintf(program, string(props1)) + props2, err := json.Marshal(tc.props2) + require.NoError(t, err) + program2 := fmt.Sprintf(program, string(props2)) + pt := pulcheck.PulCheck(t, bridgedProvider, program1) + pt.Up() + + pulumiYamlPath := filepath.Join(pt.CurrentStack().Workspace().WorkDir(), "Pulumi.yaml") + + err = os.WriteFile(pulumiYamlPath, []byte(program2), 0o600) + require.NoError(t, err) + + res := pt.Preview(optpreview.Diff()) + t.Logf(res.StdOut) + tc.expected.Equal(t, res.StdOut) + }) + } +} From fa5ba4caf8895bd591767ee65f305804f1addb11 Mon Sep 17 00:00:00 2001 From: Venelin Date: Wed, 3 Jul 2024 16:22:53 +0100 Subject: [PATCH 2/7] update --- pkg/tests/schema_pulumi_test.go | 74 ++++----------------------------- 1 file changed, 7 insertions(+), 67 deletions(-) diff --git a/pkg/tests/schema_pulumi_test.go b/pkg/tests/schema_pulumi_test.go index 98e574b2d..6b1e2a36f 100644 --- a/pkg/tests/schema_pulumi_test.go +++ b/pkg/tests/schema_pulumi_test.go @@ -1553,18 +1553,8 @@ Resources: autogold.Expect(`Previewing update (test): pulumi:pulumi:Stack: (same) [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] - ~ prov:index/test:Test: (update) - [id=newid] - [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] - + listProps: [ - + [0]: "val" - ] - + listProps: [ - + [0]: "val" - ] Resources: - ~ 1 to update - 1 unchanged + 2 unchanged `), }, { @@ -1595,18 +1585,8 @@ Resources: autogold.Expect(`Previewing update (test): pulumi:pulumi:Stack: (same) [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] - ~ prov:index/test:Test: (update) - [id=newid] - [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] - - listProps: [ - - [0]: "val" - ] - - listProps: [ - - [0]: "val" - ] Resources: - ~ 1 to update - 1 unchanged + 2 unchanged `), }, { @@ -1786,18 +1766,8 @@ Resources: autogold.Expect(`Previewing update (test): pulumi:pulumi:Stack: (same) [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] - ~ prov:index/test:Test: (update) - [id=newid] - [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] - + setProps: [ - + [0]: "val" - ] - + setProps: [ - + [0]: "val" - ] Resources: - ~ 1 to update - 1 unchanged + 2 unchanged `), }, { @@ -1828,18 +1798,8 @@ Resources: autogold.Expect(`Previewing update (test): pulumi:pulumi:Stack: (same) [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] - ~ prov:index/test:Test: (update) - [id=newid] - [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] - - setProps: [ - - [0]: "val" - ] - - setProps: [ - - [0]: "val" - ] Resources: - ~ 1 to update - 1 unchanged + 2 unchanged `), }, { @@ -1853,7 +1813,7 @@ Resources: [id=newid] [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] ~ setProps: [ - ~ [0]: "val2" => "val1" + + [0]: "val1" ~ [1]: "val3" => "val2" + [2]: "val3" ] @@ -2019,18 +1979,8 @@ Resources: autogold.Expect(`Previewing update (test): pulumi:pulumi:Stack: (same) [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] - ~ prov:index/test:Test: (update) - [id=newid] - [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] - + mapProp: { - + key: "val" - } - + mapProp: { - + key: "val" - } Resources: - ~ 1 to update - 1 unchanged + 2 unchanged `), }, { @@ -2061,18 +2011,8 @@ Resources: autogold.Expect(`Previewing update (test): pulumi:pulumi:Stack: (same) [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] - ~ prov:index/test:Test: (update) - [id=newid] - [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] - - mapProp: { - - key: "val" - } - - mapProp: { - - key: "val" - } Resources: - ~ 1 to update - 1 unchanged + 2 unchanged `), }, { From 8f4752e174a0f2b2d00a0037d0c7de03ca0cad5f Mon Sep 17 00:00:00 2001 From: Venelin Date: Mon, 22 Jul 2024 15:47:42 +0300 Subject: [PATCH 3/7] add todos --- pkg/tests/schema_pulumi_test.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/tests/schema_pulumi_test.go b/pkg/tests/schema_pulumi_test.go index 885ee7cac..61fbfaf62 100644 --- a/pkg/tests/schema_pulumi_test.go +++ b/pkg/tests/schema_pulumi_test.go @@ -1511,6 +1511,7 @@ Resources: 2 unchanged `), }, + // TODO: duplicated diff { "list added", map[string]interface{}{}, @@ -1532,6 +1533,7 @@ Resources: 1 unchanged `), }, + // TODO: missing diff { "list added empty", map[string]interface{}{}, @@ -1543,6 +1545,7 @@ Resources: 2 unchanged `), }, + // TODO: duplicated diff { "list removed", map[string]interface{}{"listProps": []interface{}{"val"}}, @@ -1564,6 +1567,7 @@ Resources: 1 unchanged `), }, + // TODO: missing diff { "list removed empty", map[string]interface{}{"listProps": []interface{}{}}, @@ -1724,6 +1728,7 @@ Resources: 2 unchanged `), }, + // TODO: duplicated diff { "set added", map[string]interface{}{}, @@ -1745,6 +1750,7 @@ Resources: 1 unchanged `), }, + // TODO: missing diff { "set added empty", map[string]interface{}{}, @@ -1756,6 +1762,7 @@ Resources: 2 unchanged `), }, + // TODO: duplicated diff { "set removed", map[string]interface{}{"setProps": []interface{}{"val"}}, @@ -1777,6 +1784,7 @@ Resources: 1 unchanged `), }, + // TODO: missing diff { "set removed empty", map[string]interface{}{"setProps": []interface{}{}}, @@ -1799,7 +1807,7 @@ Resources: [id=newid] [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] ~ setProps: [ - + [0]: "val1" + ~ [0]: "val2" => "val1" ~ [1]: "val3" => "val2" + [2]: "val3" ] @@ -1859,7 +1867,7 @@ Resources: [id=newid] [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] ~ setProps: [ - ~ [0]: "val1" => "val2" + - [0]: "val1" ~ [1]: "val2" => "val3" - [2]: "val3" ] @@ -1888,6 +1896,7 @@ Resources: 1 unchanged `), }, + // TODO: This one is pretty wrong. { "set element removed middle", map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, @@ -1937,6 +1946,7 @@ Resources: 2 unchanged `), }, + // TODO: duplicated diff { "map added", map[string]interface{}{}, @@ -1958,6 +1968,7 @@ Resources: 1 unchanged `), }, + // TODO: missing diff { "map added empty", map[string]interface{}{}, @@ -1969,6 +1980,7 @@ Resources: 2 unchanged `), }, + // TODO: duplicated diff { "map removed", map[string]interface{}{"mapProp": map[string]interface{}{"key": "val"}}, @@ -1990,6 +2002,7 @@ Resources: 1 unchanged `), }, + // TODO: missing diff { "map removed empty", map[string]interface{}{"mapProp": map[string]interface{}{}}, @@ -2001,6 +2014,7 @@ Resources: 2 unchanged `), }, + // TODO: duplicated diff { "map element added", map[string]interface{}{"mapProp": map[string]interface{}{}}, @@ -2078,6 +2092,7 @@ Resources: `), }, } { + tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() props1, err := json.Marshal(tc.props1) From b1fc7b4d318023153f46ef3ac76d0b70f81bd222 Mon Sep 17 00:00:00 2001 From: Venelin Date: Tue, 23 Jul 2024 14:32:03 +0300 Subject: [PATCH 4/7] update test --- pkg/tests/schema_pulumi_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/tests/schema_pulumi_test.go b/pkg/tests/schema_pulumi_test.go index 61fbfaf62..a61dce217 100644 --- a/pkg/tests/schema_pulumi_test.go +++ b/pkg/tests/schema_pulumi_test.go @@ -1796,6 +1796,7 @@ Resources: 2 unchanged `), }, + // TODO: wrong { "set element added front", map[string]interface{}{"setProps": []interface{}{"val2", "val3"}}, @@ -1807,7 +1808,7 @@ Resources: [id=newid] [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] ~ setProps: [ - ~ [0]: "val2" => "val1" + + [0]: "val1" ~ [1]: "val3" => "val2" + [2]: "val3" ] @@ -1867,7 +1868,7 @@ Resources: [id=newid] [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] ~ setProps: [ - - [0]: "val1" + ~ [0]: "val1" => "val2" ~ [1]: "val2" => "val3" - [2]: "val3" ] From 97132027d7ac4b19a6f7298ba68333c0ee6fd223 Mon Sep 17 00:00:00 2001 From: Venelin Date: Tue, 23 Jul 2024 14:51:03 +0300 Subject: [PATCH 5/7] add todos --- pkg/tests/schema_pulumi_test.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/tests/schema_pulumi_test.go b/pkg/tests/schema_pulumi_test.go index a61dce217..4f0918dfa 100644 --- a/pkg/tests/schema_pulumi_test.go +++ b/pkg/tests/schema_pulumi_test.go @@ -1511,7 +1511,7 @@ Resources: 2 unchanged `), }, - // TODO: duplicated diff + // TODO[pulumi/pulumi-terraform-bridge#2234]: Duplicated diff { "list added", map[string]interface{}{}, @@ -1533,7 +1533,7 @@ Resources: 1 unchanged `), }, - // TODO: missing diff + // TODO[pulumi/pulumi-terraform-bridge#2233]: Missing diff { "list added empty", map[string]interface{}{}, @@ -1545,7 +1545,7 @@ Resources: 2 unchanged `), }, - // TODO: duplicated diff + // TODO[pulumi/pulumi-terraform-bridge#2234]: Duplicated diff { "list removed", map[string]interface{}{"listProps": []interface{}{"val"}}, @@ -1567,7 +1567,7 @@ Resources: 1 unchanged `), }, - // TODO: missing diff + // TODO[pulumi/pulumi-terraform-bridge#2233]: Missing diff { "list removed empty", map[string]interface{}{"listProps": []interface{}{}}, @@ -1728,7 +1728,7 @@ Resources: 2 unchanged `), }, - // TODO: duplicated diff + // TODO[pulumi/pulumi-terraform-bridge#2234]: Duplicated diff { "set added", map[string]interface{}{}, @@ -1750,7 +1750,7 @@ Resources: 1 unchanged `), }, - // TODO: missing diff + // TODO[pulumi/pulumi-terraform-bridge#2233]: Missing diff { "set added empty", map[string]interface{}{}, @@ -1762,7 +1762,7 @@ Resources: 2 unchanged `), }, - // TODO: duplicated diff + // TODO[pulumi/pulumi-terraform-bridge#2234]: Duplicated diff { "set removed", map[string]interface{}{"setProps": []interface{}{"val"}}, @@ -1784,7 +1784,7 @@ Resources: 1 unchanged `), }, - // TODO: missing diff + // TODO[pulumi/pulumi-terraform-bridge#2233]: Missing diff { "set removed empty", map[string]interface{}{"setProps": []interface{}{}}, @@ -1796,7 +1796,7 @@ Resources: 2 unchanged `), }, - // TODO: wrong + // TODO[pulumi/pulumi-terraform-bridge#2235]: Wrong number of additions { "set element added front", map[string]interface{}{"setProps": []interface{}{"val2", "val3"}}, @@ -1897,7 +1897,7 @@ Resources: 1 unchanged `), }, - // TODO: This one is pretty wrong. + // TODO[pulumi/pulumi-terraform-bridge#2235]: Wrong number of removals { "set element removed middle", map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, @@ -1947,7 +1947,7 @@ Resources: 2 unchanged `), }, - // TODO: duplicated diff + // TODO[pulumi/pulumi-terraform-bridge#2234]: Duplicated diff { "map added", map[string]interface{}{}, @@ -1969,7 +1969,7 @@ Resources: 1 unchanged `), }, - // TODO: missing diff + // TODO[pulumi/pulumi-terraform-bridge#2233]: Missing diff { "map added empty", map[string]interface{}{}, @@ -1981,7 +1981,7 @@ Resources: 2 unchanged `), }, - // TODO: duplicated diff + // TODO[pulumi/pulumi-terraform-bridge#2234]: Duplicated diff { "map removed", map[string]interface{}{"mapProp": map[string]interface{}{"key": "val"}}, @@ -2003,7 +2003,7 @@ Resources: 1 unchanged `), }, - // TODO: missing diff + // TODO[pulumi/pulumi-terraform-bridge#2233]: Missing diff { "map removed empty", map[string]interface{}{"mapProp": map[string]interface{}{}}, @@ -2015,7 +2015,7 @@ Resources: 2 unchanged `), }, - // TODO: duplicated diff + // TODO[pulumi/pulumi-terraform-bridge#2234]: Duplicated diff { "map element added", map[string]interface{}{"mapProp": map[string]interface{}{}}, From 0f841766710ea8e1e9a61153ee62dce004844aee Mon Sep 17 00:00:00 2001 From: Venelin Date: Tue, 20 Aug 2024 12:24:01 +0100 Subject: [PATCH 6/7] lint --- pkg/tests/schema_pulumi_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/tests/schema_pulumi_test.go b/pkg/tests/schema_pulumi_test.go index e9b108084..e437ea6d4 100755 --- a/pkg/tests/schema_pulumi_test.go +++ b/pkg/tests/schema_pulumi_test.go @@ -2586,4 +2586,4 @@ Resources: tc.expected.Equal(t, res.StdOut) }) } -} \ No newline at end of file +} From 671e6fef02919d9b7ec95d7e84ac24372a46b3e6 Mon Sep 17 00:00:00 2001 From: Venelin Date: Tue, 20 Aug 2024 12:52:21 +0100 Subject: [PATCH 7/7] comment out non-deterministic tests --- pkg/tests/schema_pulumi_test.go | 124 ++++++++++++++++---------------- 1 file changed, 64 insertions(+), 60 deletions(-) diff --git a/pkg/tests/schema_pulumi_test.go b/pkg/tests/schema_pulumi_test.go index e437ea6d4..87fd3f66b 100755 --- a/pkg/tests/schema_pulumi_test.go +++ b/pkg/tests/schema_pulumi_test.go @@ -2268,26 +2268,27 @@ Resources: `), }, // TODO[pulumi/pulumi-terraform-bridge#2235]: Wrong number of additions - { - "set element added front", - map[string]interface{}{"setProps": []interface{}{"val2", "val3"}}, - map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, - autogold.Expect(`Previewing update (test): - pulumi:pulumi:Stack: (same) - [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] - ~ prov:index/test:Test: (update) - [id=newid] - [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] - ~ setProps: [ - + [0]: "val1" - ~ [1]: "val3" => "val2" - + [2]: "val3" - ] -Resources: - ~ 1 to update - 1 unchanged -`), - }, + // TODO[pulumi/pulumi-terraform-bridge#2325]: Non-deterministic output + // { + // "set element added front", + // map[string]interface{}{"setProps": []interface{}{"val2", "val3"}}, + // map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, + // autogold.Expect(`Previewing update (test): + // pulumi:pulumi:Stack: (same) + // [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + // ~ prov:index/test:Test: (update) + // [id=newid] + // [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + // ~ setProps: [ + // ~ [0]: "val2" => "val1" + // ~ [1]: "val3" => "val2" + // + [2]: "val3" + // ] + // Resources: + // ~ 1 to update + // 1 unchanged + // `), + // }, { "set element added back", map[string]interface{}{"setProps": []interface{}{"val1", "val2"}}, @@ -2308,26 +2309,28 @@ Resources: 1 unchanged `), }, - { - "set element added middle", - map[string]interface{}{"setProps": []interface{}{"val1", "val3"}}, - map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, - autogold.Expect(`Previewing update (test): - pulumi:pulumi:Stack: (same) - [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] - ~ prov:index/test:Test: (update) - [id=newid] - [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] - ~ setProps: [ - [0]: "val1" - ~ [1]: "val3" => "val2" - + [2]: "val3" - ] -Resources: - ~ 1 to update - 1 unchanged -`), - }, + // TODO[pulumi/pulumi-terraform-bridge#2235]: Wrong number of additions + // TODO[pulumi/pulumi-terraform-bridge#2325]: Non-deterministic output + // { + // "set element added middle", + // map[string]interface{}{"setProps": []interface{}{"val1", "val3"}}, + // map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, + // autogold.Expect(`Previewing update (test): + // pulumi:pulumi:Stack: (same) + // [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + // ~ prov:index/test:Test: (update) + // [id=newid] + // [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + // ~ setProps: [ + // [0]: "val1" + // + [1]: "val2" + // + [2]: "val3" + // ] + // Resources: + // ~ 1 to update + // 1 unchanged + // `), + // }, { "set element removed front", map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, @@ -2369,26 +2372,27 @@ Resources: `), }, // TODO[pulumi/pulumi-terraform-bridge#2235]: Wrong number of removals - { - "set element removed middle", - map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, - map[string]interface{}{"setProps": []interface{}{"val1", "val3"}}, - autogold.Expect(`Previewing update (test): - pulumi:pulumi:Stack: (same) - [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] - ~ prov:index/test:Test: (update) - [id=newid] - [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] - ~ setProps: [ - [0]: "val1" - - [1]: "val2" - - [2]: "val3" - ] -Resources: - ~ 1 to update - 1 unchanged -`), - }, + // TODO[pulumi/pulumi-terraform-bridge#2325]: Non-deterministic output + // { + // "set element removed middle", + // map[string]interface{}{"setProps": []interface{}{"val1", "val2", "val3"}}, + // map[string]interface{}{"setProps": []interface{}{"val1", "val3"}}, + // autogold.Expect(`Previewing update (test): + // pulumi:pulumi:Stack: (same) + // [urn=urn:pulumi:test::test::pulumi:pulumi:Stack::test-test] + // ~ prov:index/test:Test: (update) + // [id=newid] + // [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes] + // ~ setProps: [ + // [0]: "val1" + // ~ [1]: "val2" => "val3" + // - [2]: "val3" + // ] + // Resources: + // ~ 1 to update + // 1 unchanged + // `), + // }, { "set element changed", map[string]interface{}{"setProps": []interface{}{"val1"}},