From 3e2989daf1f165bd6a714781aafd769d4a2ea0fc Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 15 Sep 2014 23:52:27 -0700 Subject: [PATCH] config/module: test Git --- config/module/get_file_test.go | 10 ---------- config/module/get_git_test.go | 27 +++++++++++++++++++++++++++ config/module/module_test.go | 9 +++++++++ config/module/test-fixtures/basic-git | 1 + 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 config/module/get_git_test.go create mode 160000 config/module/test-fixtures/basic-git diff --git a/config/module/get_file_test.go b/config/module/get_file_test.go index 6cde4befc..7cc69bccb 100644 --- a/config/module/get_file_test.go +++ b/config/module/get_file_test.go @@ -1,7 +1,6 @@ package module import ( - "net/url" "os" "path/filepath" "testing" @@ -103,12 +102,3 @@ func TestFileGetter_dirSymlink(t *testing.T) { t.Fatalf("err: %s", err) } } - -func testModuleURL(n string) *url.URL { - u, err := url.Parse(testModule(n)) - if err != nil { - panic(err) - } - - return u -} diff --git a/config/module/get_git_test.go b/config/module/get_git_test.go new file mode 100644 index 000000000..46f50a277 --- /dev/null +++ b/config/module/get_git_test.go @@ -0,0 +1,27 @@ +package module + +import ( + "os" + "path/filepath" + "testing" +) + +func TestGitGetter_impl(t *testing.T) { + var _ Getter = new(GitGetter) +} + +func TestGitGetter(t *testing.T) { + g := new(GitGetter) + dst := tempDir(t) + + // With a dir that doesn't exist + if err := g.Get(dst, testModuleURL("basic-git")); err != nil { + t.Fatalf("err: %s", err) + } + + // Verify the main file exists + mainPath := filepath.Join(dst, "main.tf") + if _, err := os.Stat(mainPath); err != nil { + t.Fatalf("err: %s", err) + } +} diff --git a/config/module/module_test.go b/config/module/module_test.go index 41f15e315..bd72f0862 100644 --- a/config/module/module_test.go +++ b/config/module/module_test.go @@ -46,6 +46,15 @@ func testModule(n string) string { return url.String() } +func testModuleURL(n string) *url.URL { + u, err := url.Parse(testModule(n)) + if err != nil { + panic(err) + } + + return u +} + func testStorage(t *testing.T) Storage { return &FolderStorage{StorageDir: tempDir(t)} } diff --git a/config/module/test-fixtures/basic-git b/config/module/test-fixtures/basic-git new file mode 160000 index 000000000..7f872b3fd --- /dev/null +++ b/config/module/test-fixtures/basic-git @@ -0,0 +1 @@ +Subproject commit 7f872b3fd8504ba63330261b35073a1c4f35383d