github.com/arvindram03/terraform@v0.3.7-0.20150212015210-408f838db36d/config/module/module_test.go (about) 1 package module 2 3 import ( 4 "io/ioutil" 5 "net/url" 6 "os" 7 "path/filepath" 8 "testing" 9 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 testModule(n string) string { 37 p := filepath.Join(fixtureDir, n) 38 p, err := filepath.Abs(p) 39 if err != nil { 40 panic(err) 41 } 42 return fmtFileURL(p) 43 } 44 45 func testModuleURL(n string) *url.URL { 46 u, err := urlParse(testModule(n)) 47 if err != nil { 48 panic(err) 49 } 50 51 return u 52 } 53 54 func testStorage(t *testing.T) Storage { 55 return &FolderStorage{StorageDir: tempDir(t)} 56 }