github.com/paybyphone/terraform@v0.9.5-0.20170613192930-9706042ddd51/config/module/module_test.go (about) 1 package module 2 3 import ( 4 "io/ioutil" 5 "os" 6 "path/filepath" 7 "testing" 8 9 "github.com/hashicorp/go-getter" 10 "github.com/hashicorp/terraform/config" 11 ) 12 13 const fixtureDir = "./test-fixtures" 14 15 func tempDir(t *testing.T) string { 16 dir, err := ioutil.TempDir("", "tf") 17 if err != nil { 18 t.Fatalf("err: %s", err) 19 } 20 if err := os.RemoveAll(dir); err != nil { 21 t.Fatalf("err: %s", err) 22 } 23 24 return dir 25 } 26 27 func testConfig(t *testing.T, n string) *config.Config { 28 c, err := config.LoadDir(filepath.Join(fixtureDir, n)) 29 if err != nil { 30 t.Fatalf("err: %s", err) 31 } 32 33 return c 34 } 35 36 func testStorage(t *testing.T) getter.Storage { 37 return &getter.FolderStorage{StorageDir: tempDir(t)} 38 }