add tests for get from tar subdir
Test that we can get a subdirectory from a tarball (or any other "packed" source that we support). The 'tar-subdir-to-parent' test highlights a regression where the subdirectory module references a module in its parent directory. This breaks the intended use ofr the subdirectory and the implementation in go-getter. We need to fix this in terraform, and possible plan warnings and deprecations for this type of source.
This commit is contained in:
parent
f846beecbc
commit
38569c8508
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
module "foo" {
|
||||
source = "./foo.tgz//sub"
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
module "foo" {
|
||||
// the module in sub references sibling module baz via "../baz"
|
||||
source = "./foo.tgz//sub"
|
||||
}
|
|
@ -209,40 +209,50 @@ func TestTreeLoad_parentRef(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTreeLoad_subdir(t *testing.T) {
|
||||
storage := testStorage(t)
|
||||
tree := NewTree("", testConfig(t, "basic-subdir"))
|
||||
|
||||
if tree.Loaded() {
|
||||
t.Fatal("should not be loaded")
|
||||
fixtures := []string{
|
||||
"basic-subdir",
|
||||
"basic-tar-subdir",
|
||||
"tar-sbudir-to-parent",
|
||||
}
|
||||
|
||||
// This should error because we haven't gotten things yet
|
||||
if err := tree.Load(storage, GetModeNone); err == nil {
|
||||
t.Fatal("should error")
|
||||
}
|
||||
for _, tc := range fixtures {
|
||||
t.Run(tc, func(t *testing.T) {
|
||||
storage := testStorage(t)
|
||||
tree := NewTree("", testConfig(t, tc))
|
||||
|
||||
if tree.Loaded() {
|
||||
t.Fatal("should not be loaded")
|
||||
}
|
||||
if tree.Loaded() {
|
||||
t.Fatal("should not be loaded")
|
||||
}
|
||||
|
||||
// This should get things
|
||||
if err := tree.Load(storage, GetModeGet); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
// This should error because we haven't gotten things yet
|
||||
if err := tree.Load(storage, GetModeNone); err == nil {
|
||||
t.Fatal("should error")
|
||||
}
|
||||
|
||||
if !tree.Loaded() {
|
||||
t.Fatal("should be loaded")
|
||||
}
|
||||
if tree.Loaded() {
|
||||
t.Fatal("should not be loaded")
|
||||
}
|
||||
|
||||
// This should no longer error
|
||||
if err := tree.Load(storage, GetModeNone); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
// This should get things
|
||||
if err := tree.Load(storage, GetModeGet); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(tree.String())
|
||||
expected := strings.TrimSpace(treeLoadSubdirStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: \n\n%s", actual)
|
||||
if !tree.Loaded() {
|
||||
t.Fatal("should be loaded")
|
||||
}
|
||||
|
||||
// This should no longer error
|
||||
if err := tree.Load(storage, GetModeNone); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(tree.String())
|
||||
expected := strings.TrimSpace(treeLoadSubdirStr)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: \n\n%s", actual)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue