diff --git a/terraform/state_add.go b/terraform/state_add.go index 34dd72e54..54a5732a5 100644 --- a/terraform/state_add.go +++ b/terraform/state_add.go @@ -131,7 +131,7 @@ func stateAddFunc_Module_Module(s *State, fromAddr, addr *ResourceAddress, raw i // It is! Strip the leading prefix and attach that to our address extra := item.Path[len(src.Path)+1:] addrCopy := addr.Copy() - addrCopy.Path = append(addrCopy.Path, extra) + addrCopy.Path = append(addrCopy.Path, extra...) // Add it s.Add(fromAddr.String(), addrCopy.String(), item) diff --git a/terraform/state_add_test.go b/terraform/state_add_test.go index 0ace9bf86..4ecf5aab0 100644 --- a/terraform/state_add_test.go +++ b/terraform/state_add_test.go @@ -231,7 +231,7 @@ func TestStateAdd(t *testing.T) { // Should be ignored &ModuleState{ - Path: []string{"root", "bar", "child2"}, + Path: []string{"root", "baz", "child2"}, Resources: map[string]*ResourceState{ "test_instance.foo": &ResourceState{ Type: "test_instance", @@ -246,6 +246,11 @@ func TestStateAdd(t *testing.T) { &State{}, &State{ Modules: []*ModuleState{ + &ModuleState{ + Path: []string{"root", "bar"}, + Resources: map[string]*ResourceState{}, + }, + &ModuleState{ Path: []string{"root", "bar", "child1"}, Resources: map[string]*ResourceState{ @@ -499,8 +504,8 @@ func TestStateAdd(t *testing.T) { // Verify equality if !tc.One.Equal(tc.Two) { - t.Fatalf("Bad: %s\n\n%#v\n\n%#v", k, tc.One, tc.Two) - //t.Fatalf("Bad: %s\n\n%s\n\n%s", k, tc.One.String(), tc.Two.String()) + //t.Fatalf("Bad: %s\n\n%#v\n\n%#v", k, tc.One, tc.Two) + t.Fatalf("Bad: %s\n\n%s\n\n%s", k, tc.One.String(), tc.Two.String()) } } }