|
|
|
@ -611,117 +611,6 @@ func TestTreeProviders_basic(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestTreeProviders_implicit(t *testing.T) {
|
|
|
|
|
storage := testStorage(t, nil)
|
|
|
|
|
tree := NewTree("", testConfig(t, "implicit-parent-providers"))
|
|
|
|
|
|
|
|
|
|
storage.Mode = GetModeGet
|
|
|
|
|
if err := tree.Load(storage); err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var child *Tree
|
|
|
|
|
for _, c := range tree.Children() {
|
|
|
|
|
if c.Name() == "child" {
|
|
|
|
|
child = c
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if child == nil {
|
|
|
|
|
t.Fatal("could not find module 'child'")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// child should have inherited foo
|
|
|
|
|
providers := child.config.ProviderConfigsByFullName()
|
|
|
|
|
foo := providers["foo"]
|
|
|
|
|
|
|
|
|
|
if foo == nil {
|
|
|
|
|
t.Fatal("could not find provider 'foo' in child module")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual([]string{RootName}, foo.Path) {
|
|
|
|
|
t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Path)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expected := map[string]interface{}{
|
|
|
|
|
"value": "from root",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(expected, foo.RawConfig.RawMap()) {
|
|
|
|
|
t.Fatalf(`expected "foo" config %#v, got: %#v`, expected, foo.RawConfig.RawMap())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestTreeProviders_implicitMultiLevel(t *testing.T) {
|
|
|
|
|
storage := testStorage(t, nil)
|
|
|
|
|
tree := NewTree("", testConfig(t, "implicit-grandparent-providers"))
|
|
|
|
|
|
|
|
|
|
storage.Mode = GetModeGet
|
|
|
|
|
if err := tree.Load(storage); err != nil {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var child, grandchild *Tree
|
|
|
|
|
for _, c := range tree.Children() {
|
|
|
|
|
if c.Name() == "child" {
|
|
|
|
|
child = c
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if child == nil {
|
|
|
|
|
t.Fatal("could not find module 'child'")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, c := range child.Children() {
|
|
|
|
|
if c.Name() == "grandchild" {
|
|
|
|
|
grandchild = c
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if grandchild == nil {
|
|
|
|
|
t.Fatal("could not find module 'grandchild'")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// child should have inherited foo
|
|
|
|
|
providers := child.config.ProviderConfigsByFullName()
|
|
|
|
|
foo := providers["foo"]
|
|
|
|
|
|
|
|
|
|
if foo == nil {
|
|
|
|
|
t.Fatal("could not find provider 'foo' in child module")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual([]string{RootName}, foo.Path) {
|
|
|
|
|
t.Fatalf(`expected foo scope of {"root"}, got %#v`, foo.Path)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expected := map[string]interface{}{
|
|
|
|
|
"value": "from root",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(expected, foo.RawConfig.RawMap()) {
|
|
|
|
|
t.Fatalf(`expected "foo" config %#v, got: %#v`, expected, foo.RawConfig.RawMap())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// grandchild should have inherited bar
|
|
|
|
|
providers = grandchild.config.ProviderConfigsByFullName()
|
|
|
|
|
bar := providers["bar"]
|
|
|
|
|
|
|
|
|
|
if bar == nil {
|
|
|
|
|
t.Fatal("could not find provider 'bar' in grandchild module")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual([]string{RootName, "child"}, bar.Path) {
|
|
|
|
|
t.Fatalf(`expected bar scope of {"root", "child"}, got %#v`, bar.Path)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expected = map[string]interface{}{
|
|
|
|
|
"value": "from child",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(expected, bar.RawConfig.RawMap()) {
|
|
|
|
|
t.Fatalf(`expected "bar" config %#v, got: %#v`, expected, bar.RawConfig.RawMap())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestTreeLoad_conflictingSubmoduleNames(t *testing.T) {
|
|
|
|
|
storage := testStorage(t, nil)
|
|
|
|
|
tree := NewTree("", testConfig(t, "conficting-submodule-names"))
|
|
|
|
|