github.com/bendemaree/terraform@v0.5.4-0.20150613200311-f50d97d6eee6/config/module/folder_storage_test.go (about) 1 package module 2 3 import ( 4 "os" 5 "path/filepath" 6 "testing" 7 ) 8 9 func TestFolderStorage_impl(t *testing.T) { 10 var _ Storage = new(FolderStorage) 11 } 12 13 func TestFolderStorage(t *testing.T) { 14 s := &FolderStorage{StorageDir: tempDir(t)} 15 16 module := testModule("basic") 17 18 // A module shouldn't exist at first... 19 _, ok, err := s.Dir(module) 20 if err != nil { 21 t.Fatalf("err: %s", err) 22 } 23 if ok { 24 t.Fatal("should not exist") 25 } 26 27 key := "foo" 28 29 // We can get it 30 err = s.Get(key, module, false) 31 if err != nil { 32 t.Fatalf("err: %s", err) 33 } 34 35 // Now the module exists 36 dir, ok, err := s.Dir(key) 37 if err != nil { 38 t.Fatalf("err: %s", err) 39 } 40 if !ok { 41 t.Fatal("should exist") 42 } 43 44 mainPath := filepath.Join(dir, "main.tf") 45 if _, err := os.Stat(mainPath); err != nil { 46 t.Fatalf("err: %s", err) 47 } 48 }