|
|
|
|
@ -376,6 +376,41 @@ func TestResourceChange_JSON(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
},
|
|
|
|
|
"in-place update (tuple of different types)": {
|
|
|
|
|
Action: plans.Update,
|
|
|
|
|
Mode: addrs.ManagedResourceMode,
|
|
|
|
|
Before: cty.ObjectVal(map[string]cty.Value{
|
|
|
|
|
"id": cty.StringVal("i-02ae66f368e8518a9"),
|
|
|
|
|
"json_field": cty.StringVal(`{"aaa": [42, {"foo":"bar"}, "value"]}`),
|
|
|
|
|
}),
|
|
|
|
|
After: cty.ObjectVal(map[string]cty.Value{
|
|
|
|
|
"id": cty.UnknownVal(cty.String),
|
|
|
|
|
"json_field": cty.StringVal(`{"aaa": [42, {"foo":"baz"}, "value"]}`),
|
|
|
|
|
}),
|
|
|
|
|
Schema: &configschema.Block{
|
|
|
|
|
Attributes: map[string]*configschema.Attribute{
|
|
|
|
|
"id": {Type: cty.String, Optional: true, Computed: true},
|
|
|
|
|
"json_field": {Type: cty.String, Optional: true},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
RequiredReplace: cty.NewPathSet(),
|
|
|
|
|
ExpectedOutput: ` # test_instance.example will be updated in-place
|
|
|
|
|
~ resource "test_instance" "example" {
|
|
|
|
|
~ id = "i-02ae66f368e8518a9" -> (known after apply)
|
|
|
|
|
~ json_field = jsonencode(
|
|
|
|
|
~ {
|
|
|
|
|
~ aaa = [
|
|
|
|
|
42,
|
|
|
|
|
~ {
|
|
|
|
|
~ foo = "bar" -> "baz"
|
|
|
|
|
},
|
|
|
|
|
"value",
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
},
|
|
|
|
|
"force-new update": {
|
|
|
|
|
@ -730,7 +765,6 @@ func TestResourceChange_JSON(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
},
|
|
|
|
|
// TODO: JSON with unknown values inside
|
|
|
|
|
}
|
|
|
|
|
runTestCases(t, testCases)
|
|
|
|
|
}
|
|
|
|
|
|