add a test
This commit is contained in:
parent
91d7332471
commit
4e08ea6a92
|
@ -0,0 +1,9 @@
|
|||
|
||||
variable "image_id" {
|
||||
type = string
|
||||
default = "ami-something-something"
|
||||
validation {
|
||||
condition = length(var.image_id) > 4 && substr(var.image_id, 0, 4) == "ami-"
|
||||
error_message = "The image_id value must be a valid AMI id, starting with \"ami-\"."
|
||||
}
|
||||
}
|
|
@ -357,6 +357,28 @@ func TestParse_variables(t *testing.T) {
|
|||
},
|
||||
false,
|
||||
},
|
||||
|
||||
{"valid validation block",
|
||||
defaultParser,
|
||||
parseTestArgs{"testdata/variables/validation/valid.pkr.hcl", nil, nil},
|
||||
&PackerConfig{
|
||||
Basedir: filepath.Join("testdata", "variables", "validation"),
|
||||
InputVariables: Variables{
|
||||
"image_id": &Variable{
|
||||
DefaultValue: cty.StringVal("ami-something-something"),
|
||||
Name: "image_id",
|
||||
Validations: []*VariableValidation{
|
||||
&VariableValidation{
|
||||
ErrorMessage: `The image_id value must be a valid AMI id, starting with "ami-".`,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
false, false,
|
||||
[]packer.Build{},
|
||||
false,
|
||||
},
|
||||
}
|
||||
testParse(t, tests)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue