terraform: more test cases

This commit is contained in:
Mitchell Hashimoto 2014-07-22 08:27:16 -07:00
parent fed0a89c36
commit c6474b3e5c
5 changed files with 30 additions and 0 deletions

View File

@ -23,6 +23,10 @@ func (e *Error) Error() string {
len(e.Errors), strings.Join(points, "\n"))
}
func (e *Error) GoString() string {
return fmt.Sprintf("*%#v", *e)
}
// ErrorAppend is a helper function that will append more errors
// onto a Error in order to create a larger multi-error. If the
// original error is not a Error, it will be turned into one.

View File

@ -1050,6 +1050,14 @@ func TestContextApply_vars(t *testing.T) {
},
})
w, e := ctx.Validate()
if len(w) > 0 {
t.Fatalf("bad: %#v", w)
}
if len(e) > 0 {
t.Fatalf("bad: %s", e)
}
if _, err := ctx.Plan(nil); err != nil {
t.Fatalf("err: %s", err)
}

View File

@ -18,4 +18,13 @@ func TestSMCUserVariables(t *testing.T) {
if len(errs) != 0 {
t.Fatalf("err: %#v", errs)
}
// Mapping element override
errs = smcUserVariables(c, map[string]string{
"foo": "bar",
"map.foo": "baz",
})
if len(errs) != 0 {
t.Fatalf("err: %#v", errs)
}
}

View File

@ -9,6 +9,8 @@ variable "bar" {
default = "baz"
}
variable "foo" {}
resource "aws_instance" "foo" {
num = "2"
bar = "${var.bar}"

View File

@ -6,3 +6,10 @@ variable "foo" {
variable "bar" {
default = "baz"
}
# Mapping
variable "map" {
default = {
"foo" = "bar";
}
}