add more test for var files
This commit is contained in:
parent
6b48feb817
commit
710ebdcef5
|
@ -91,6 +91,9 @@ func testParse(t *testing.T, tests []parseTest) {
|
|||
if variable.DefaultValue.GoString() != value.DefaultValue.GoString() {
|
||||
t.Fatalf("Parser.parse() input variable %s expected '%s' but was '%s'", name, value.DefaultValue.GoString(), variable.DefaultValue.GoString())
|
||||
}
|
||||
if diff := cmp.Diff(variable.VarfileValue.GoString(), value.VarfileValue.GoString()); diff != "" {
|
||||
t.Fatalf("Parser.parse(): varfile value differs: %s", diff)
|
||||
}
|
||||
} else {
|
||||
t.Fatalf("Parser.parse() missing input variable. %s", name)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
variable "foo" {
|
||||
type = string
|
||||
default = "bar"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
foo = "wee"
|
|
@ -240,6 +240,35 @@ func TestParse_variables(t *testing.T) {
|
|||
[]packer.Build{},
|
||||
false,
|
||||
},
|
||||
|
||||
{"set variable from var-file",
|
||||
defaultParser,
|
||||
parseTestArgs{"testdata/variables/foo-string.variable.pkr.hcl", nil, []string{"testdata/variables/set-foo-too-wee.hcl"}},
|
||||
&PackerConfig{
|
||||
Basedir: filepath.Join("testdata", "variables"),
|
||||
InputVariables: Variables{
|
||||
"foo": &Variable{
|
||||
DefaultValue: cty.StringVal("bar"),
|
||||
Name: "foo",
|
||||
VarfileValue: cty.StringVal("wee"),
|
||||
},
|
||||
},
|
||||
},
|
||||
false, false,
|
||||
[]packer.Build{},
|
||||
false,
|
||||
},
|
||||
|
||||
{"unknown variable from var-file",
|
||||
defaultParser,
|
||||
parseTestArgs{"testdata/variables/empty.pkr.hcl", nil, []string{"testdata/variables/set-foo-too-wee.hcl"}},
|
||||
&PackerConfig{
|
||||
Basedir: filepath.Join("testdata", "variables"),
|
||||
},
|
||||
true, false,
|
||||
[]packer.Build{},
|
||||
false,
|
||||
},
|
||||
}
|
||||
testParse(t, tests)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue