helper/schema: test that validatefunc is not called with computed vals

This commit is contained in:
Mitchell Hashimoto 2015-06-23 22:10:46 -07:00
parent 8daa459e57
commit 4e7fcd4f42
1 changed files with 22 additions and 0 deletions

View File

@ -3469,6 +3469,7 @@ func TestSchemaMap_Validate(t *testing.T) {
}, },
Err: true, Err: true,
}, },
"ValidateFunc gets decoded type": { "ValidateFunc gets decoded type": {
Schema: map[string]*Schema{ Schema: map[string]*Schema{
"maybe": &Schema{ "maybe": &Schema{
@ -3486,6 +3487,27 @@ func TestSchemaMap_Validate(t *testing.T) {
"maybe": "true", "maybe": "true",
}, },
}, },
"ValidateFunc is not called with a computed value": {
Schema: map[string]*Schema{
"validate_me": &Schema{
Type: TypeString,
Required: true,
ValidateFunc: func(v interface{}) (ws []string, es []error) {
es = append(es, fmt.Errorf("something is not right here"))
return
},
},
},
Config: map[string]interface{}{
"validate_me": "${var.foo}",
},
Vars: map[string]string{
"var.foo": config.UnknownVariableValue,
},
Err: false,
},
} }
for tn, tc := range cases { for tn, tc := range cases {