From 880d971328164426e56c0efdb2dee0a297ee4869 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 8 May 2018 14:30:52 -0700 Subject: [PATCH] core: TestStateAddModule old-style output Although the AddModule method now takes a new-style module address as an argument, internally we're still shimming it to a []string. Therefore this test needs to still expect [][]string as a result, rather tan []addrs.ModuleInstance. --- terraform/state_test.go | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/terraform/state_test.go b/terraform/state_test.go index 8ace3315c1..5f6790e4ae 100644 --- a/terraform/state_test.go +++ b/terraform/state_test.go @@ -10,6 +10,7 @@ import ( "strings" "testing" + "github.com/davecgh/go-spew/spew" "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/config" @@ -54,16 +55,16 @@ func TestStateValidate(t *testing.T) { func TestStateAddModule(t *testing.T) { cases := []struct { In []addrs.ModuleInstance - Out []addrs.ModuleInstance + Out [][]string }{ { []addrs.ModuleInstance{ addrs.RootModuleInstance, addrs.RootModuleInstance.Child("child", addrs.NoKey), }, - []addrs.ModuleInstance{ - addrs.RootModuleInstance, - addrs.RootModuleInstance.Child("child", addrs.NoKey), + [][]string{ + []string{"root"}, + []string{"root", "child"}, }, }, @@ -74,11 +75,11 @@ func TestStateAddModule(t *testing.T) { addrs.RootModuleInstance, addrs.RootModuleInstance.Child("bar", addrs.NoKey), }, - []addrs.ModuleInstance{ - addrs.RootModuleInstance, - addrs.RootModuleInstance.Child("bar", addrs.NoKey), - addrs.RootModuleInstance.Child("foo", addrs.NoKey), - addrs.RootModuleInstance.Child("foo", addrs.NoKey).Child("bar", addrs.NoKey), + [][]string{ + []string{"root"}, + []string{"root", "bar"}, + []string{"root", "foo"}, + []string{"root", "foo", "bar"}, }, }, // Same last element, different middle element @@ -90,12 +91,12 @@ func TestStateAddModule(t *testing.T) { addrs.RootModuleInstance.Child("bar", addrs.NoKey).Child("bar", addrs.NoKey), // ...this one. addrs.RootModuleInstance.Child("bar", addrs.NoKey), }, - []addrs.ModuleInstance{ - addrs.RootModuleInstance, - addrs.RootModuleInstance.Child("bar", addrs.NoKey), - addrs.RootModuleInstance.Child("foo", addrs.NoKey), - addrs.RootModuleInstance.Child("bar", addrs.NoKey).Child("bar", addrs.NoKey), - addrs.RootModuleInstance.Child("foo", addrs.NoKey).Child("bar", addrs.NoKey), + [][]string{ + []string{"root"}, + []string{"root", "bar"}, + []string{"root", "foo"}, + []string{"root", "bar", "bar"}, + []string{"root", "foo", "bar"}, }, }, } @@ -112,7 +113,7 @@ func TestStateAddModule(t *testing.T) { } if !reflect.DeepEqual(actual, tc.Out) { - t.Fatalf("In: %#v\n\nOut: %#v", tc.In, actual) + t.Fatalf("wrong result\ninput: %sgot: %#v\nwant: %#v", spew.Sdump(tc.In), actual, tc.Out) } } }