2014-09-14 02:45:56 +02:00
|
|
|
package module
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFolderStorage_impl(t *testing.T) {
|
|
|
|
var _ Storage = new(FolderStorage)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFolderStorage(t *testing.T) {
|
|
|
|
s := &FolderStorage{StorageDir: tempDir(t)}
|
|
|
|
|
|
|
|
module := testModule("basic")
|
|
|
|
|
|
|
|
// A module shouldn't exist at first...
|
|
|
|
_, ok, err := s.Dir(module)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
if ok {
|
|
|
|
t.Fatal("should not exist")
|
|
|
|
}
|
|
|
|
|
2015-04-08 01:44:24 +02:00
|
|
|
key := "foo"
|
|
|
|
|
2014-09-14 02:45:56 +02:00
|
|
|
// We can get it
|
2015-04-08 01:44:24 +02:00
|
|
|
err = s.Get(key, module, false)
|
2014-09-14 02:45:56 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now the module exists
|
2015-04-08 01:44:24 +02:00
|
|
|
dir, ok, err := s.Dir(key)
|
2014-09-14 02:45:56 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
if !ok {
|
|
|
|
t.Fatal("should exist")
|
|
|
|
}
|
|
|
|
|
|
|
|
mainPath := filepath.Join(dir, "main.tf")
|
|
|
|
if _, err := os.Stat(mainPath); err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
}
|