core: fix tests for checkInputVariables
The contract for this function has changed as part of the 0.12 reorganization so that, while before it would accept a partial variables map if all missing variables were optional, it now expects that the caller has already collected values for all variables and is just checking them for type-correctness here.
This commit is contained in:
parent
ce41553d56
commit
feff252700
|
@ -9,36 +9,42 @@ import (
|
||||||
func TestSMCUserVariables(t *testing.T) {
|
func TestSMCUserVariables(t *testing.T) {
|
||||||
c := testModule(t, "smc-uservars")
|
c := testModule(t, "smc-uservars")
|
||||||
|
|
||||||
// Required variables not set
|
// No variables set
|
||||||
diags := checkInputVariables(c.Module.Variables, nil)
|
diags := checkInputVariables(c.Module.Variables, nil)
|
||||||
if !diags.HasErrors() {
|
if !diags.HasErrors() {
|
||||||
t.Fatal("check succeeded, but want errors")
|
t.Fatal("check succeeded, but want errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required variables set, optional variables unset
|
// Required variables set, optional variables unset
|
||||||
|
// This is still an error at this layer, since it's the caller's
|
||||||
|
// responsibility to have already merged in any default values.
|
||||||
diags = checkInputVariables(c.Module.Variables, InputValues{
|
diags = checkInputVariables(c.Module.Variables, InputValues{
|
||||||
"foo": &InputValue{
|
"foo": &InputValue{
|
||||||
Value: cty.StringVal("bar"),
|
Value: cty.StringVal("bar"),
|
||||||
SourceType: ValueFromCLIArg,
|
SourceType: ValueFromCLIArg,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if diags.HasErrors() {
|
|
||||||
t.Fatalf("unexpected errors: %s", diags.Err())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mapping complete override
|
|
||||||
diags = checkInputVariables(c.Module.Variables, InputValues{
|
|
||||||
"foo": &InputValue{
|
|
||||||
Value: cty.StringVal("bar"),
|
|
||||||
SourceType: ValueFromCLIArg,
|
|
||||||
},
|
|
||||||
"map": &InputValue{
|
|
||||||
Value: cty.StringVal("baz"),
|
|
||||||
SourceType: ValueFromCLIArg,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if !diags.HasErrors() {
|
if !diags.HasErrors() {
|
||||||
t.Fatal("check succeeded, but want errors")
|
t.Fatal("check succeeded, but want errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All variables set
|
||||||
|
diags = checkInputVariables(c.Module.Variables, InputValues{
|
||||||
|
"foo": &InputValue{
|
||||||
|
Value: cty.StringVal("bar"),
|
||||||
|
SourceType: ValueFromCLIArg,
|
||||||
|
},
|
||||||
|
"bar": &InputValue{
|
||||||
|
Value: cty.StringVal("baz"),
|
||||||
|
SourceType: ValueFromCLIArg,
|
||||||
|
},
|
||||||
|
"map": &InputValue{
|
||||||
|
Value: cty.StringVal("baz"), // okay because config has no type constraint
|
||||||
|
SourceType: ValueFromCLIArg,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if diags.HasErrors() {
|
||||||
|
//t.Fatal("check succeeded, but want errors")
|
||||||
|
t.Fatalf("unexpected errors: %s", diags.Err())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue