|
|
|
|
@ -3325,16 +3325,46 @@ func TestSchemaMap_InternalValidate(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"computed-only field with validateFunc": {
|
|
|
|
|
map[string]*Schema{
|
|
|
|
|
"string": &Schema{
|
|
|
|
|
Type: TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
ValidateFunc: func(v interface{}, k string) (ws []string, es []error) {
|
|
|
|
|
es = append(es, fmt.Errorf("this is not fine"))
|
|
|
|
|
return
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
true,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
"computed-only field with diffSuppressFunc": {
|
|
|
|
|
map[string]*Schema{
|
|
|
|
|
"string": &Schema{
|
|
|
|
|
Type: TypeString,
|
|
|
|
|
Computed: true,
|
|
|
|
|
DiffSuppressFunc: func(k, old, new string, d *ResourceData) bool {
|
|
|
|
|
// Always suppress any diff
|
|
|
|
|
return false
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
true,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for tn, tc := range cases {
|
|
|
|
|
err := schemaMap(tc.In).InternalValidate(nil)
|
|
|
|
|
if err != nil != tc.Err {
|
|
|
|
|
if tc.Err {
|
|
|
|
|
t.Fatalf("%q: Expected error did not occur:\n\n%#v", tn, tc.In)
|
|
|
|
|
t.Run(tn, func(t *testing.T) {
|
|
|
|
|
err := schemaMap(tc.In).InternalValidate(nil)
|
|
|
|
|
if err != nil != tc.Err {
|
|
|
|
|
if tc.Err {
|
|
|
|
|
t.Fatalf("%q: Expected error did not occur:\n\n%#v", tn, tc.In)
|
|
|
|
|
}
|
|
|
|
|
t.Fatalf("%q: Unexpected error occurred: %s\n\n%#v", tn, err, tc.In)
|
|
|
|
|
}
|
|
|
|
|
t.Fatalf("%q: Unexpected error occurred:\n\n%#v", tn, tc.In)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|