mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
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.
This commit is contained in:
parent
3ed396ad5c
commit
880d971328
@ -10,6 +10,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/hashicorp/terraform/addrs"
|
"github.com/hashicorp/terraform/addrs"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/config"
|
"github.com/hashicorp/terraform/config"
|
||||||
@ -54,16 +55,16 @@ func TestStateValidate(t *testing.T) {
|
|||||||
func TestStateAddModule(t *testing.T) {
|
func TestStateAddModule(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
In []addrs.ModuleInstance
|
In []addrs.ModuleInstance
|
||||||
Out []addrs.ModuleInstance
|
Out [][]string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
[]addrs.ModuleInstance{
|
[]addrs.ModuleInstance{
|
||||||
addrs.RootModuleInstance,
|
addrs.RootModuleInstance,
|
||||||
addrs.RootModuleInstance.Child("child", addrs.NoKey),
|
addrs.RootModuleInstance.Child("child", addrs.NoKey),
|
||||||
},
|
},
|
||||||
[]addrs.ModuleInstance{
|
[][]string{
|
||||||
addrs.RootModuleInstance,
|
[]string{"root"},
|
||||||
addrs.RootModuleInstance.Child("child", addrs.NoKey),
|
[]string{"root", "child"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -74,11 +75,11 @@ func TestStateAddModule(t *testing.T) {
|
|||||||
addrs.RootModuleInstance,
|
addrs.RootModuleInstance,
|
||||||
addrs.RootModuleInstance.Child("bar", addrs.NoKey),
|
addrs.RootModuleInstance.Child("bar", addrs.NoKey),
|
||||||
},
|
},
|
||||||
[]addrs.ModuleInstance{
|
[][]string{
|
||||||
addrs.RootModuleInstance,
|
[]string{"root"},
|
||||||
addrs.RootModuleInstance.Child("bar", addrs.NoKey),
|
[]string{"root", "bar"},
|
||||||
addrs.RootModuleInstance.Child("foo", addrs.NoKey),
|
[]string{"root", "foo"},
|
||||||
addrs.RootModuleInstance.Child("foo", addrs.NoKey).Child("bar", addrs.NoKey),
|
[]string{"root", "foo", "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Same last element, different middle element
|
// 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).Child("bar", addrs.NoKey), // ...this one.
|
||||||
addrs.RootModuleInstance.Child("bar", addrs.NoKey),
|
addrs.RootModuleInstance.Child("bar", addrs.NoKey),
|
||||||
},
|
},
|
||||||
[]addrs.ModuleInstance{
|
[][]string{
|
||||||
addrs.RootModuleInstance,
|
[]string{"root"},
|
||||||
addrs.RootModuleInstance.Child("bar", addrs.NoKey),
|
[]string{"root", "bar"},
|
||||||
addrs.RootModuleInstance.Child("foo", addrs.NoKey),
|
[]string{"root", "foo"},
|
||||||
addrs.RootModuleInstance.Child("bar", addrs.NoKey).Child("bar", addrs.NoKey),
|
[]string{"root", "bar", "bar"},
|
||||||
addrs.RootModuleInstance.Child("foo", addrs.NoKey).Child("bar", addrs.NoKey),
|
[]string{"root", "foo", "bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -112,7 +113,7 @@ func TestStateAddModule(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, tc.Out) {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user