terraform: fix state add with multiple ModuleStates

This commit is contained in:
Mitchell Hashimoto 2016-08-18 17:13:53 -04:00
parent a44c8b8760
commit 3892cc4e91
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 9 additions and 4 deletions

View File

@ -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)

View File

@ -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())
}
}
}