Skip to content

Commit 20a909d

Browse files
PF Diff cross tests for computed in set blocks (#2638)
This change adds additional testing for Diff in PF for sets involving Computed. The following schemas are covered: - Set block with a Computed attribute - Set block with a Computed attribute and RequiresReplace on the non-computed attribute - Set block with a Computed attribute and RequiresReplace on the computed attribute - Set block with a Computed attribute and RequiresReplace on the block - Set block with a Computed attribute and no UseStateForUnknown on the Computed attribute For each of these we test both when the Computed attribute is specified in the program and when it is not. For each of these schemas we test the full set of scenarios added in #2592 This should give us some confidence that the changes we are making by adding Detailed Diff for PF are good for Computed properties. I will categorize all the issues here as a follow-up before merging #2629
1 parent 7a21638 commit 20a909d

File tree

241 files changed

+10941
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+10941
-74
lines changed

pkg/pf/tests/diff_set_test.go

Lines changed: 299 additions & 74 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
tfbridgetests.testOutput{
2+
initialValue: &[]string{},
3+
changeValue: &[]string{"value"},
4+
tfOut: `
5+
Terraform used the selected providers to generate the following execution
6+
plan. Resource actions are indicated with the following symbols:
7+
+/- create replacement and then destroy
8+
9+
Terraform will perform the following actions:
10+
11+
# testprovider_test.res must be replaced
12+
+/- resource "testprovider_test" "res" {
13+
~ id = "test-id" -> (known after apply)
14+
15+
+ key { # forces replacement
16+
+ computed = (known after apply)
17+
+ nested = "value"
18+
}
19+
}
20+
21+
Plan: 1 to add, 0 to change, 1 to destroy.
22+
23+
`,
24+
pulumiOut: `Previewing update (test):
25+
pulumi:pulumi:Stack: (same)
26+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
27+
+-testprovider:index/test:Test: (replace)
28+
[id=test-id]
29+
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
30+
~ id : "test-id" => output<string>
31+
~ keys: [
32+
+ [0]: {
33+
+ computed: output<string>
34+
+ nested : "value"
35+
}
36+
]
37+
Resources:
38+
+-1 to replace
39+
1 unchanged
40+
`,
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
tfbridgetests.testOutput{
2+
initialValue: &[]string{
3+
"val1",
4+
"val2",
5+
},
6+
changeValue: &[]string{
7+
"val1",
8+
"val2",
9+
"val3",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
+/- create replacement and then destroy
15+
16+
Terraform will perform the following actions:
17+
18+
# testprovider_test.res must be replaced
19+
+/- resource "testprovider_test" "res" {
20+
~ id = "test-id" -> (known after apply)
21+
22+
- key { # forces replacement
23+
- computed = "computed-val1" -> null
24+
- nested = "val1" -> null
25+
}
26+
- key { # forces replacement
27+
- computed = "computed-val2" -> null
28+
- nested = "val2" -> null
29+
}
30+
+ key { # forces replacement
31+
+ computed = (known after apply)
32+
+ nested = "val1"
33+
}
34+
+ key { # forces replacement
35+
+ computed = (known after apply)
36+
+ nested = "val2"
37+
}
38+
+ key { # forces replacement
39+
+ computed = (known after apply)
40+
+ nested = "val3"
41+
}
42+
}
43+
44+
Plan: 1 to add, 0 to change, 1 to destroy.
45+
46+
`,
47+
pulumiOut: `Previewing update (test):
48+
pulumi:pulumi:Stack: (same)
49+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
50+
+-testprovider:index/test:Test: (replace)
51+
[id=test-id]
52+
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
53+
~ id : "test-id" => output<string>
54+
~ keys: [
55+
~ [0]: {
56+
~ computed: "computed-val1" => output<string>
57+
nested : "val1"
58+
}
59+
~ [1]: {
60+
~ computed: "computed-val2" => output<string>
61+
nested : "val2"
62+
}
63+
+ [2]: {
64+
+ computed: output<string>
65+
+ nested : "val3"
66+
}
67+
]
68+
Resources:
69+
+-1 to replace
70+
1 unchanged
71+
`,
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
tfbridgetests.testOutput{
2+
initialValue: &[]string{
3+
"val2",
4+
"val3",
5+
},
6+
changeValue: &[]string{
7+
"val2",
8+
"val3",
9+
"val1",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
+/- create replacement and then destroy
15+
16+
Terraform will perform the following actions:
17+
18+
# testprovider_test.res must be replaced
19+
+/- resource "testprovider_test" "res" {
20+
~ id = "test-id" -> (known after apply)
21+
22+
- key { # forces replacement
23+
- computed = "computed-val2" -> null
24+
- nested = "val2" -> null
25+
}
26+
- key { # forces replacement
27+
- computed = "computed-val3" -> null
28+
- nested = "val3" -> null
29+
}
30+
+ key { # forces replacement
31+
+ computed = (known after apply)
32+
+ nested = "val1"
33+
}
34+
+ key { # forces replacement
35+
+ computed = (known after apply)
36+
+ nested = "val2"
37+
}
38+
+ key { # forces replacement
39+
+ computed = (known after apply)
40+
+ nested = "val3"
41+
}
42+
}
43+
44+
Plan: 1 to add, 0 to change, 1 to destroy.
45+
46+
`,
47+
pulumiOut: `Previewing update (test):
48+
pulumi:pulumi:Stack: (same)
49+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
50+
+-testprovider:index/test:Test: (replace)
51+
[id=test-id]
52+
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
53+
~ id : "test-id" => output<string>
54+
~ keys: [
55+
~ [0]: {
56+
~ computed: "computed-val2" => output<string>
57+
~ nested : "val2" => "val1"
58+
}
59+
~ [1]: {
60+
~ computed: "computed-val3" => output<string>
61+
~ nested : "val3" => "val2"
62+
}
63+
+ [2]: {
64+
+ computed: output<string>
65+
+ nested : "val3"
66+
}
67+
]
68+
Resources:
69+
+-1 to replace
70+
1 unchanged
71+
`,
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
tfbridgetests.testOutput{
2+
initialValue: &[]string{
3+
"val2",
4+
"val3",
5+
},
6+
changeValue: &[]string{
7+
"val1",
8+
"val2",
9+
"val3",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
+/- create replacement and then destroy
15+
16+
Terraform will perform the following actions:
17+
18+
# testprovider_test.res must be replaced
19+
+/- resource "testprovider_test" "res" {
20+
~ id = "test-id" -> (known after apply)
21+
22+
- key { # forces replacement
23+
- computed = "computed-val2" -> null
24+
- nested = "val2" -> null
25+
}
26+
- key { # forces replacement
27+
- computed = "computed-val3" -> null
28+
- nested = "val3" -> null
29+
}
30+
+ key { # forces replacement
31+
+ computed = (known after apply)
32+
+ nested = "val1"
33+
}
34+
+ key { # forces replacement
35+
+ computed = (known after apply)
36+
+ nested = "val2"
37+
}
38+
+ key { # forces replacement
39+
+ computed = (known after apply)
40+
+ nested = "val3"
41+
}
42+
}
43+
44+
Plan: 1 to add, 0 to change, 1 to destroy.
45+
46+
`,
47+
pulumiOut: `Previewing update (test):
48+
pulumi:pulumi:Stack: (same)
49+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
50+
+-testprovider:index/test:Test: (replace)
51+
[id=test-id]
52+
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
53+
~ id : "test-id" => output<string>
54+
~ keys: [
55+
~ [0]: {
56+
~ computed: "computed-val2" => output<string>
57+
~ nested : "val2" => "val1"
58+
}
59+
~ [1]: {
60+
~ computed: "computed-val3" => output<string>
61+
~ nested : "val3" => "val2"
62+
}
63+
+ [2]: {
64+
+ computed: output<string>
65+
+ nested : "val3"
66+
}
67+
]
68+
Resources:
69+
+-1 to replace
70+
1 unchanged
71+
`,
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
tfbridgetests.testOutput{
2+
initialValue: &[]string{
3+
"val3",
4+
"val1",
5+
},
6+
changeValue: &[]string{
7+
"val2",
8+
"val3",
9+
"val1",
10+
},
11+
tfOut: `
12+
Terraform used the selected providers to generate the following execution
13+
plan. Resource actions are indicated with the following symbols:
14+
+/- create replacement and then destroy
15+
16+
Terraform will perform the following actions:
17+
18+
# testprovider_test.res must be replaced
19+
+/- resource "testprovider_test" "res" {
20+
~ id = "test-id" -> (known after apply)
21+
22+
- key { # forces replacement
23+
- computed = "computed-val1" -> null
24+
- nested = "val1" -> null
25+
}
26+
- key { # forces replacement
27+
- computed = "computed-val3" -> null
28+
- nested = "val3" -> null
29+
}
30+
+ key { # forces replacement
31+
+ computed = (known after apply)
32+
+ nested = "val1"
33+
}
34+
+ key { # forces replacement
35+
+ computed = (known after apply)
36+
+ nested = "val2"
37+
}
38+
+ key { # forces replacement
39+
+ computed = (known after apply)
40+
+ nested = "val3"
41+
}
42+
}
43+
44+
Plan: 1 to add, 0 to change, 1 to destroy.
45+
46+
`,
47+
pulumiOut: `Previewing update (test):
48+
pulumi:pulumi:Stack: (same)
49+
[urn=urn:pulumi:test::project::pulumi:pulumi:Stack::project-test]
50+
+-testprovider:index/test:Test: (replace)
51+
[id=test-id]
52+
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
53+
~ id : "test-id" => output<string>
54+
~ keys: [
55+
~ [0]: {
56+
~ computed: "computed-val1" => output<string>
57+
nested : "val1"
58+
}
59+
~ [1]: {
60+
~ computed: "computed-val3" => output<string>
61+
~ nested : "val3" => "val2"
62+
}
63+
+ [2]: {
64+
+ computed: output<string>
65+
+ nested : "val3"
66+
}
67+
]
68+
Resources:
69+
+-1 to replace
70+
1 unchanged
71+
`,
72+
}

0 commit comments

Comments
 (0)