github.com/jgadling/terraform@v0.3.8-0.20150227214559-abd68c2c87bc/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  	// We can get it
    28  	err = s.Get(module, false)
    29  	if err != nil {
    30  		t.Fatalf("err: %s", err)
    31  	}
    32  
    33  	// Now the module exists
    34  	dir, ok, err := s.Dir(module)
    35  	if err != nil {
    36  		t.Fatalf("err: %s", err)
    37  	}
    38  	if !ok {
    39  		t.Fatal("should exist")
    40  	}
    41  
    42  	mainPath := filepath.Join(dir, "main.tf")
    43  	if _, err := os.Stat(mainPath); err != nil {
    44  		t.Fatalf("err: %s", err)
    45  	}
    46  }