terraform: fix state add with multiple ModuleStates
This commit is contained in:
parent
a44c8b8760
commit
3892cc4e91
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue