github.com/chalford/terraform@v0.3.7-0.20150113080010-a78c69a8c81f/terraform/semantics_test.go (about) 1 package terraform 2 3 import ( 4 "testing" 5 ) 6 7 func TestSMCUserVariables(t *testing.T) { 8 c := testConfig(t, "smc-uservars") 9 10 // Required variables not set 11 errs := smcUserVariables(c, nil) 12 if len(errs) == 0 { 13 t.Fatal("should have errors") 14 } 15 16 // Required variables set, optional variables unset 17 errs = smcUserVariables(c, map[string]string{"foo": "bar"}) 18 if len(errs) != 0 { 19 t.Fatalf("err: %#v", errs) 20 } 21 22 // Mapping element override 23 errs = smcUserVariables(c, map[string]string{ 24 "foo": "bar", 25 "map.foo": "baz", 26 }) 27 if len(errs) != 0 { 28 t.Fatalf("err: %#v", errs) 29 } 30 31 // Mapping complete override 32 errs = smcUserVariables(c, map[string]string{ 33 "foo": "bar", 34 "map": "baz", 35 }) 36 if len(errs) == 0 { 37 t.Fatal("should have errors") 38 } 39 40 }