Skip to content

Commit

Permalink
recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
VenelinMartinov committed Jan 15, 2025
1 parent d9846f0 commit 86c44b9
Show file tree
Hide file tree
Showing 50 changed files with 1,409 additions and 71 deletions.
29 changes: 2 additions & 27 deletions pkg/tests/diff_test/detailed_diff_map_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package tests

import (
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hexops/autogold/v2"
"github.com/zclconf/go-cty/cty"

crosstests "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests"
)

func TestSDKv2DetailedDiffMap(t *testing.T) {
Expand All @@ -26,7 +22,7 @@ func TestSDKv2DetailedDiffMap(t *testing.T) {
}

var nilVal map[string]string
schemaValueMakerPairs, scenarios := generatePrimitiveSchemaValueMakerPairs(
schemaValueMakerPairs, scenarios := generateBaseTests(
schema.TypeMap, &schema.Schema{Type: schema.TypeString}, ctyMaker,
map[string]string{"key": "val1"}, map[string]string{"key": "val2"},
map[string]string{"key": "computedVal"}, map[string]string{"key": "defaultVal"}, nilVal)
Expand All @@ -37,26 +33,5 @@ func TestSDKv2DetailedDiffMap(t *testing.T) {
changeValue: ref(map[string]string{"key2": "val1"}),
})

for _, schemaValueMakerPair := range schemaValueMakerPairs {
t.Run(schemaValueMakerPair.name, func(t *testing.T) {
t.Parallel()
for _, scenario := range scenarios {
t.Run(scenario.name, func(t *testing.T) {
if strings.Contains(schemaValueMakerPair.name, "required") &&
(scenario.initialValue == nil || scenario.changeValue == nil) {
t.Skip("Required fields cannot be unset")
}
t.Parallel()
diff := crosstests.Diff(t, &schemaValueMakerPair.schema, schemaValueMakerPair.valueMaker(scenario.initialValue), schemaValueMakerPair.valueMaker(scenario.changeValue))
autogold.ExpectFile(t, testOutput{
initialValue: scenario.initialValue,
changeValue: scenario.changeValue,
tfOut: diff.TFOut,
pulumiOut: diff.PulumiOut,
detailedDiff: diff.PulumiDiff.DetailedDiff,
})
})
}
})
}
runSDKv2TestMatrix(t, schemaValueMakerPairs, scenarios)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests.testOutput{
initialValue: map[string]string{},
changeValue: map[string]string{"key": "val"},
initialValue: &map[string]string{},
changeValue: &map[string]string{"key": "val1"},
tfOut: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
Expand All @@ -10,9 +10,9 @@ Terraform will perform the following actions:

# crossprovider_test_res.example will be updated in-place
~ resource "crossprovider_test_res" "example" {
id = "newid"
+ map_prop = {
+ "key" = "val"
id = "newid"
+ prop = {
+ "key" = "val1"
}
}

Expand All @@ -25,12 +25,12 @@ Plan: 0 to add, 1 to change, 0 to destroy.
~ crossprovider:index/testRes:TestRes: (update)
[id=newid]
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
+ mapProp: {
+ key: "val"
+ prop: {
+ key: "val1"
}
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"mapProp": map[string]interface{}{}},
detailedDiff: map[string]interface{}{"prop": map[string]interface{}{}},
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
tests.testOutput{
initialValue: map[string]string{
"key": "val",
initialValue: &map[string]string{
"key": "val1",
},
changeValue: map[string]string{"key": "val2"},
changeValue: &map[string]string{"key": "val2"},
tfOut: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
Expand All @@ -12,9 +12,9 @@ Terraform will perform the following actions:

# crossprovider_test_res.example will be updated in-place
~ resource "crossprovider_test_res" "example" {
id = "newid"
~ map_prop = {
~ "key" = "val" -> "val2"
id = "newid"
~ prop = {
~ "key" = "val1" -> "val2"
}
}

Expand All @@ -27,12 +27,12 @@ Plan: 0 to add, 1 to change, 0 to destroy.
~ crossprovider:index/testRes:TestRes: (update)
[id=newid]
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
~ mapProp: {
~ key: "val" => "val2"
~ prop: {
~ key: "val1" => "val2"
}
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"mapProp.key": map[string]interface{}{"kind": "UPDATE"}},
detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}},
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
tests.testOutput{
initialValue: map[string]string{
"key": "val",
initialValue: &map[string]string{
"key": "val1",
},
changeValue: map[string]string{"key2": "val"},
changeValue: &map[string]string{"key2": "val1"},
tfOut: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
Expand All @@ -12,10 +12,10 @@ Terraform will perform the following actions:

# crossprovider_test_res.example will be updated in-place
~ resource "crossprovider_test_res" "example" {
id = "newid"
~ map_prop = {
- "key" = "val" -> null
+ "key2" = "val"
id = "newid"
~ prop = {
- "key" = "val1" -> null
+ "key2" = "val1"
}
}

Expand All @@ -28,16 +28,16 @@ Plan: 0 to add, 1 to change, 0 to destroy.
~ crossprovider:index/testRes:TestRes: (update)
[id=newid]
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
~ mapProp: {
- key : "val"
+ key2: "val"
~ prop: {
- key : "val1"
+ key2: "val1"
}
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{
"mapProp.key": map[string]interface{}{"kind": "DELETE"},
"mapProp.key2": map[string]interface{}{},
"prop.key": map[string]interface{}{"kind": "DELETE"},
"prop.key2": map[string]interface{}{},
},
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
tests.testOutput{
initialValue: map[string]string{
"key": "val",
initialValue: &map[string]string{
"key": "val1",
},
changeValue: map[string]string{},
changeValue: &map[string]string{},
tfOut: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
Expand All @@ -12,9 +12,9 @@ Terraform will perform the following actions:

# crossprovider_test_res.example will be updated in-place
~ resource "crossprovider_test_res" "example" {
id = "newid"
~ map_prop = {
- "key" = "val" -> null
id = "newid"
~ prop = {
- "key" = "val1" -> null
}
}

Expand All @@ -27,12 +27,12 @@ Plan: 0 to add, 1 to change, 0 to destroy.
~ crossprovider:index/testRes:TestRes: (update)
[id=newid]
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
~ mapProp: {
- key: "val"
~ prop: {
- key: "val1"
}
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"mapProp.key": map[string]interface{}{"kind": "DELETE"}},
detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "DELETE"}},
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests.testOutput{
initialValue: map[string]string{},
changeValue: map[string]string{},
initialValue: &map[string]string{},
changeValue: &map[string]string{},
tfOut: `
No changes. Your infrastructure matches the configuration.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
tests.testOutput{
initialValue: map[string]string{
"key": "val",
initialValue: &map[string]string{
"key": "val1",
},
changeValue: map[string]string{"key": "val"},
changeValue: &map[string]string{"key": "val1"},
tfOut: `
No changes. Your infrastructure matches the configuration.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
tests.testOutput{
initialValue: &map[string]string{},
changeValue: &map[string]string{"key": "val1"},
tfOut: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place

Terraform will perform the following actions:

# crossprovider_test_res.example will be updated in-place
~ resource "crossprovider_test_res" "example" {
id = "id"
~ prop = {
~ "key" = "computedVal" -> "val1"
}
}

Plan: 0 to add, 1 to change, 0 to destroy.

`,
pulumiOut: `Previewing update (test):
pulumi:pulumi:Stack: (same)
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
~ crossprovider:index/testRes:TestRes: (update)
[id=id]
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
~ prop: {
~ key: "computedVal" => "val1"
}
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
tests.testOutput{
initialValue: &map[string]string{
"key": "val1",
},
changeValue: &map[string]string{"key": "val2"},
tfOut: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place

Terraform will perform the following actions:

# crossprovider_test_res.example will be updated in-place
~ resource "crossprovider_test_res" "example" {
id = "id"
~ prop = {
~ "key" = "val1" -> "val2"
}
}

Plan: 0 to add, 1 to change, 0 to destroy.

`,
pulumiOut: `Previewing update (test):
pulumi:pulumi:Stack: (same)
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
~ crossprovider:index/testRes:TestRes: (update)
[id=id]
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
~ prop: {
~ key: "val1" => "val2"
}
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"prop.key": map[string]interface{}{"kind": "UPDATE"}},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
tests.testOutput{
initialValue: &map[string]string{
"key": "val1",
},
changeValue: &map[string]string{"key2": "val1"},
tfOut: `
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place

Terraform will perform the following actions:

# crossprovider_test_res.example will be updated in-place
~ resource "crossprovider_test_res" "example" {
id = "id"
~ prop = {
- "key" = "val1" -> null
+ "key2" = "val1"
}
}

Plan: 0 to add, 1 to change, 0 to destroy.

`,
pulumiOut: `Previewing update (test):
pulumi:pulumi:Stack: (same)
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
~ crossprovider:index/testRes:TestRes: (update)
[id=id]
[urn=urn:pulumi:test::project::crossprovider:index/testRes:TestRes::example]
~ prop: {
- key : "val1"
+ key2: "val1"
}
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{
"prop.key": map[string]interface{}{"kind": "DELETE"},
"prop.key2": map[string]interface{}{},
},
}
Loading

0 comments on commit 86c44b9

Please sign in to comment.