2014-09-14 02:45:56 +02:00
|
|
|
package module
|
|
|
|
|
|
|
|
import (
|
2014-09-14 03:54:12 +02:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
2014-09-14 02:45:56 +02:00
|
|
|
"path/filepath"
|
2014-09-14 03:54:12 +02:00
|
|
|
"testing"
|
2014-09-14 23:46:45 +02:00
|
|
|
|
2015-10-15 22:36:58 +02:00
|
|
|
"github.com/hashicorp/go-getter"
|
2014-09-14 23:46:45 +02:00
|
|
|
"github.com/hashicorp/terraform/config"
|
2014-09-14 02:45:56 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
const fixtureDir = "./test-fixtures"
|
|
|
|
|
2014-09-14 03:54:12 +02:00
|
|
|
func tempDir(t *testing.T) string {
|
|
|
|
dir, err := ioutil.TempDir("", "tf")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
if err := os.RemoveAll(dir); err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return dir
|
|
|
|
}
|
|
|
|
|
2014-09-14 23:46:45 +02:00
|
|
|
func testConfig(t *testing.T, n string) *config.Config {
|
|
|
|
c, err := config.LoadDir(filepath.Join(fixtureDir, n))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
2015-10-15 22:36:58 +02:00
|
|
|
func testStorage(t *testing.T) getter.Storage {
|
|
|
|
return &getter.FolderStorage{StorageDir: tempDir(t)}
|
2014-09-15 01:17:29 +02:00
|
|
|
}
|