command/format: Add crashing test with unknown element in set
This commit is contained in:
parent
15cd6d8300
commit
e7e8b7358f
|
@ -1002,6 +1002,80 @@ func TestResourceChange_primitiveSet(t *testing.T) {
|
|||
~ id = "i-02ae66f368e8518a9" -> (known after apply)
|
||||
+ set_field = []
|
||||
}
|
||||
`,
|
||||
},
|
||||
"in-place update to unknown": {
|
||||
Action: plans.Update,
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Before: cty.ObjectVal(map[string]cty.Value{
|
||||
"id": cty.StringVal("i-02ae66f368e8518a9"),
|
||||
"ami": cty.StringVal("ami-STATIC"),
|
||||
"set_field": cty.SetVal([]cty.Value{
|
||||
cty.StringVal("aaaa"),
|
||||
cty.StringVal("bbbb"),
|
||||
}),
|
||||
}),
|
||||
After: cty.ObjectVal(map[string]cty.Value{
|
||||
"id": cty.UnknownVal(cty.String),
|
||||
"ami": cty.StringVal("ami-STATIC"),
|
||||
"set_field": cty.UnknownVal(cty.Set(cty.String)),
|
||||
}),
|
||||
Schema: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
"id": {Type: cty.String, Optional: true, Computed: true},
|
||||
"ami": {Type: cty.String, Optional: true},
|
||||
"set_field": {Type: cty.Set(cty.String), Optional: true},
|
||||
},
|
||||
},
|
||||
RequiredReplace: cty.NewPathSet(),
|
||||
ExpectedOutput: ` # test_instance.example will be updated in-place
|
||||
~ resource "test_instance" "example" {
|
||||
ami = "ami-STATIC"
|
||||
~ id = "i-02ae66f368e8518a9" -> (known after apply)
|
||||
~ set_field = [
|
||||
- "aaaa",
|
||||
- "bbbb",
|
||||
] -> (known after apply)
|
||||
}
|
||||
`,
|
||||
},
|
||||
"in-place update to unknown element": {
|
||||
Action: plans.Update,
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Before: cty.ObjectVal(map[string]cty.Value{
|
||||
"id": cty.StringVal("i-02ae66f368e8518a9"),
|
||||
"ami": cty.StringVal("ami-STATIC"),
|
||||
"set_field": cty.SetVal([]cty.Value{
|
||||
cty.StringVal("aaaa"),
|
||||
cty.StringVal("bbbb"),
|
||||
}),
|
||||
}),
|
||||
After: cty.ObjectVal(map[string]cty.Value{
|
||||
"id": cty.UnknownVal(cty.String),
|
||||
"ami": cty.StringVal("ami-STATIC"),
|
||||
"set_field": cty.SetVal([]cty.Value{
|
||||
cty.StringVal("aaaa"),
|
||||
cty.UnknownVal(cty.String),
|
||||
}),
|
||||
}),
|
||||
Schema: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
"id": {Type: cty.String, Optional: true, Computed: true},
|
||||
"ami": {Type: cty.String, Optional: true},
|
||||
"set_field": {Type: cty.Set(cty.String), Optional: true},
|
||||
},
|
||||
},
|
||||
RequiredReplace: cty.NewPathSet(),
|
||||
ExpectedOutput: ` # test_instance.example will be updated in-place
|
||||
~ resource "test_instance" "example" {
|
||||
ami = "ami-STATIC"
|
||||
~ id = "i-02ae66f368e8518a9" -> (known after apply)
|
||||
~ set_field = [
|
||||
"aaaa",
|
||||
- "bbbb",
|
||||
~ (known after apply),
|
||||
]
|
||||
}
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue