Merge pull request #27791 from hashicorp/jbardin/test-conformance-dynamic

reverse call to TestConformance in objchange
This commit is contained in:
James Bardin 2021-02-16 15:42:12 -05:00 committed by GitHub
commit 0d63b3ec24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -219,7 +219,7 @@ func assertValueCompatible(planned, actual cty.Value, path cty.Path) []error {
// Anything goes, then // Anything goes, then
return errs return errs
} }
if problems := planned.Type().TestConformance(actual.Type()); len(problems) > 0 { if problems := actual.Type().TestConformance(planned.Type()); len(problems) > 0 {
errs = append(errs, path.NewErrorf("wrong final value type: %s", convert.MismatchMessage(actual.Type(), planned.Type()))) errs = append(errs, path.NewErrorf("wrong final value type: %s", convert.MismatchMessage(actual.Type(), planned.Type())))
// If the types don't match then we can't do any other comparisons, // If the types don't match then we can't do any other comparisons,
// so we bail early. // so we bail early.

View File

@ -260,6 +260,28 @@ func TestAssertObjectCompatible(t *testing.T) {
}), }),
[]string{}, []string{},
}, },
{
&configschema.Block{
Attributes: map[string]*configschema.Attribute{
"obj": {
Type: cty.Object(map[string]cty.Type{
"stuff": cty.DynamicPseudoType,
}),
},
},
},
cty.ObjectVal(map[string]cty.Value{
"obj": cty.ObjectVal(map[string]cty.Value{
"stuff": cty.DynamicVal,
}),
}),
cty.ObjectVal(map[string]cty.Value{
"obj": cty.ObjectVal(map[string]cty.Value{
"stuff": cty.NumberIntVal(3),
}),
}),
[]string{},
},
{ {
&configschema.Block{ &configschema.Block{
Attributes: map[string]*configschema.Attribute{ Attributes: map[string]*configschema.Attribute{