mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-14 01:13:59 -06:00
config/module: test Git
This commit is contained in:
parent
acb6d12a75
commit
3e2989daf1
@ -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
|
||||
}
|
||||
|
27
config/module/get_git_test.go
Normal file
27
config/module/get_git_test.go
Normal file
@ -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)
|
||||
}
|
||||
}
|
@ -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)}
|
||||
}
|
||||
|
1
config/module/test-fixtures/basic-git
Submodule
1
config/module/test-fixtures/basic-git
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 7f872b3fd8504ba63330261b35073a1c4f35383d
|
Loading…
Reference in New Issue
Block a user