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
|
// It is! Strip the leading prefix and attach that to our address
|
||||||
extra := item.Path[len(src.Path)+1:]
|
extra := item.Path[len(src.Path)+1:]
|
||||||
addrCopy := addr.Copy()
|
addrCopy := addr.Copy()
|
||||||
addrCopy.Path = append(addrCopy.Path, extra)
|
addrCopy.Path = append(addrCopy.Path, extra...)
|
||||||
|
|
||||||
// Add it
|
// Add it
|
||||||
s.Add(fromAddr.String(), addrCopy.String(), item)
|
s.Add(fromAddr.String(), addrCopy.String(), item)
|
||||||
|
|
|
@ -231,7 +231,7 @@ func TestStateAdd(t *testing.T) {
|
||||||
|
|
||||||
// Should be ignored
|
// Should be ignored
|
||||||
&ModuleState{
|
&ModuleState{
|
||||||
Path: []string{"root", "bar", "child2"},
|
Path: []string{"root", "baz", "child2"},
|
||||||
Resources: map[string]*ResourceState{
|
Resources: map[string]*ResourceState{
|
||||||
"test_instance.foo": &ResourceState{
|
"test_instance.foo": &ResourceState{
|
||||||
Type: "test_instance",
|
Type: "test_instance",
|
||||||
|
@ -246,6 +246,11 @@ func TestStateAdd(t *testing.T) {
|
||||||
&State{},
|
&State{},
|
||||||
&State{
|
&State{
|
||||||
Modules: []*ModuleState{
|
Modules: []*ModuleState{
|
||||||
|
&ModuleState{
|
||||||
|
Path: []string{"root", "bar"},
|
||||||
|
Resources: map[string]*ResourceState{},
|
||||||
|
},
|
||||||
|
|
||||||
&ModuleState{
|
&ModuleState{
|
||||||
Path: []string{"root", "bar", "child1"},
|
Path: []string{"root", "bar", "child1"},
|
||||||
Resources: map[string]*ResourceState{
|
Resources: map[string]*ResourceState{
|
||||||
|
@ -499,8 +504,8 @@ func TestStateAdd(t *testing.T) {
|
||||||
|
|
||||||
// Verify equality
|
// Verify equality
|
||||||
if !tc.One.Equal(tc.Two) {
|
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%#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%s\n\n%s", k, tc.One.String(), tc.Two.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue