From 0fceeaaeb05426ceba3721baa8b920253c105015 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 26 Aug 2016 13:48:21 -0700 Subject: [PATCH] config: test for var uniqueness in overrides --- config/loader_test.go | 22 +++++++++++++++++++ config/test-fixtures/dir-override-var/main.tf | 4 ++++ .../dir-override-var/main_override.tf | 3 +++ 3 files changed, 29 insertions(+) create mode 100644 config/test-fixtures/dir-override-var/main.tf create mode 100644 config/test-fixtures/dir-override-var/main_override.tf diff --git a/config/loader_test.go b/config/loader_test.go index b7d53dee5..d2a1208ec 100644 --- a/config/loader_test.go +++ b/config/loader_test.go @@ -446,6 +446,22 @@ func TestLoadDir_override(t *testing.T) { } } +func TestLoadDir_overrideVar(t *testing.T) { + c, err := LoadDir(filepath.Join(fixtureDir, "dir-override-var")) + if err != nil { + t.Fatalf("err: %s", err) + } + + if c == nil { + t.Fatal("config should not be nil") + } + + actual := variablesStr(c.Variables) + if actual != strings.TrimSpace(dirOverrideVarsVariablesStr) { + t.Fatalf("bad:\n%s", actual) + } +} + func TestLoadFile_mismatchedVariableTypes(t *testing.T) { _, err := LoadFile(filepath.Join(fixtureDir, "variable-mismatched-type.tf")) if err == nil { @@ -922,6 +938,12 @@ foo bar ` +const dirOverrideVarsVariablesStr = ` +foo + baz + bar +` + const importProvidersStr = ` aws bar diff --git a/config/test-fixtures/dir-override-var/main.tf b/config/test-fixtures/dir-override-var/main.tf new file mode 100644 index 000000000..f902801bd --- /dev/null +++ b/config/test-fixtures/dir-override-var/main.tf @@ -0,0 +1,4 @@ +variable "foo" { + default = "bar" + description = "bar" +} diff --git a/config/test-fixtures/dir-override-var/main_override.tf b/config/test-fixtures/dir-override-var/main_override.tf new file mode 100644 index 000000000..a3fd68abb --- /dev/null +++ b/config/test-fixtures/dir-override-var/main_override.tf @@ -0,0 +1,3 @@ +variable "foo" { + default = "baz" +}