github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/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  }