2014-09-14 02:45:56 +02:00
|
|
|
package module
|
|
|
|
|
|
|
|
import (
|
2014-09-14 03:54:12 +02:00
|
|
|
"io/ioutil"
|
2017-09-22 22:49:58 +02:00
|
|
|
"log"
|
2014-09-14 03:54:12 +02:00
|
|
|
"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
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/config"
|
2017-10-27 21:07:24 +02:00
|
|
|
"github.com/hashicorp/terraform/svchost/disco"
|
2014-09-14 02:45:56 +02:00
|
|
|
)
|
|
|
|
|
2017-09-22 22:49:58 +02:00
|
|
|
func init() {
|
|
|
|
if os.Getenv("TF_LOG") == "" {
|
|
|
|
log.SetOutput(ioutil.Discard)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-30 09:38:36 +02:00
|
|
|
const fixtureDir = "./testdata"
|
2014-09-14 02:45:56 +02:00
|
|
|
|
2014-09-14 03:54:12 +02:00
|
|
|
func tempDir(t *testing.T) string {
|
2017-09-09 00:18:47 +02:00
|
|
|
t.Helper()
|
2014-09-14 03:54:12 +02:00
|
|
|
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 {
|
2017-09-09 00:18:47 +02:00
|
|
|
t.Helper()
|
2014-09-14 23:46:45 +02:00
|
|
|
c, err := config.LoadDir(filepath.Join(fixtureDir, n))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
2017-10-27 21:07:24 +02:00
|
|
|
func testStorage(t *testing.T, d *disco.Disco) *Storage {
|
2017-09-09 00:18:47 +02:00
|
|
|
t.Helper()
|
2018-07-05 21:28:29 +02:00
|
|
|
return NewStorage(tempDir(t), d)
|
2017-10-27 21:07:24 +02:00
|
|
|
}
|