From 30afb492ab64120db76dae44aeb522552bb203ec Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 20 Aug 2021 14:22:58 -0400 Subject: [PATCH] fix ApplyMove test with nested modules working The addrs package can now correctly handle the combinations of nested module endpoints, which fixes these 2 tests. --- internal/refactoring/move_execute_test.go | 26 +++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/internal/refactoring/move_execute_test.go b/internal/refactoring/move_execute_test.go index 126a56ee7e..63c54a7adb 100644 --- a/internal/refactoring/move_execute_test.go +++ b/internal/refactoring/move_execute_test.go @@ -324,10 +324,10 @@ func TestApplyMoves(t *testing.T) { }, }, - "move whole module to within indexed module and instance chained": { + "move whole module to indexed module and move instance chained": { []MoveStatement{ testMoveStatement(t, "", "module.boo", "module.bar[0]"), - testMoveStatement(t, "module.bar[0]", "foo.from[0]", "foo.too[0]"), + testMoveStatement(t, "bar", "foo.from[0]", "foo.to[0]"), }, states.BuildState(func(s *states.SyncState) { s.SetResourceInstanceCurrent( @@ -345,19 +345,23 @@ func TestApplyMoves(t *testing.T) { To: instAddrs["module.bar[0].foo.from[0]"], }, instAddrs["module.bar[0].foo.from[0]"].UniqueKey(): { - From: instAddrs["module.boo.foo.from[0]"], - To: instAddrs["module.bar[0].foo.from[0]"], + From: instAddrs["module.bar[0].foo.from[0]"], + To: instAddrs["module.bar[0].foo.to[0]"], + }, + instAddrs["module.bar[0].foo.to[0]"].UniqueKey(): { + From: instAddrs["module.bar[0].foo.from[0]"], + To: instAddrs["module.bar[0].foo.to[0]"], }, }, []string{ - `module.bar[0].foo.from[0]`, + `module.bar[0].foo.to[0]`, }, }, "move instance to indexed module and instance chained": { []MoveStatement{ testMoveStatement(t, "", "module.boo.foo.from[0]", "module.bar[0].foo.from[0]"), - testMoveStatement(t, "module.bar[0]", "foo.from[0]", "foo.too[0]"), + testMoveStatement(t, "bar", "foo.from[0]", "foo.to[0]"), }, states.BuildState(func(s *states.SyncState) { s.SetResourceInstanceCurrent( @@ -375,12 +379,16 @@ func TestApplyMoves(t *testing.T) { To: instAddrs["module.bar[0].foo.from[0]"], }, instAddrs["module.bar[0].foo.from[0]"].UniqueKey(): { - From: instAddrs["module.boo.foo.from[0]"], - To: instAddrs["module.bar[0].foo.from[0]"], + From: instAddrs["module.bar[0].foo.from[0]"], + To: instAddrs["module.bar[0].foo.to[0]"], + }, + instAddrs["module.bar[0].foo.to[0]"].UniqueKey(): { + From: instAddrs["module.bar[0].foo.from[0]"], + To: instAddrs["module.bar[0].foo.to[0]"], }, }, []string{ - `module.bar[0].foo.from[0]`, + `module.bar[0].foo.to[0]`, }, }, }