github.com/jonasi/terraform@v0.6.10-0.20160125170522-e865c342cc1f/config_test.go (about) 1 package main 2 3 import ( 4 "path/filepath" 5 "reflect" 6 "testing" 7 ) 8 9 // This is the directory where our test fixtures are. 10 const fixtureDir = "./test-fixtures" 11 12 func TestLoadConfig(t *testing.T) { 13 c, err := LoadConfig(filepath.Join(fixtureDir, "config")) 14 if err != nil { 15 t.Fatalf("err: %s", err) 16 } 17 18 expected := &Config{ 19 Providers: map[string]string{ 20 "aws": "foo", 21 "do": "bar", 22 }, 23 } 24 25 if !reflect.DeepEqual(c, expected) { 26 t.Fatalf("bad: %#v", c) 27 } 28 } 29 30 func TestConfig_Merge(t *testing.T) { 31 c1 := &Config{ 32 Providers: map[string]string{ 33 "foo": "bar", 34 "bar": "blah", 35 }, 36 Provisioners: map[string]string{ 37 "local": "local", 38 "remote": "bad", 39 }, 40 } 41 42 c2 := &Config{ 43 Providers: map[string]string{ 44 "bar": "baz", 45 "baz": "what", 46 }, 47 Provisioners: map[string]string{ 48 "remote": "remote", 49 }, 50 } 51 52 expected := &Config{ 53 Providers: map[string]string{ 54 "foo": "bar", 55 "bar": "baz", 56 "baz": "what", 57 }, 58 Provisioners: map[string]string{ 59 "local": "local", 60 "remote": "remote", 61 }, 62 } 63 64 actual := c1.Merge(c2) 65 if !reflect.DeepEqual(actual, expected) { 66 t.Fatalf("bad: %#v", actual) 67 } 68 }