mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
d0519f226d
The provider input before wasn't scoped by path, which caused non-descendant parts of the graph to grab the configuration of another sub-tree. The result is that you'd often get copied provider configurations across the module barriers. See GH-2024
43 lines
1019 B
Go
43 lines
1019 B
Go
package terraform
|
|
|
|
import (
|
|
"reflect"
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
func TestBuiltinEvalContextProviderInput(t *testing.T) {
|
|
var lock sync.Mutex
|
|
cache := make(map[string]map[string]interface{})
|
|
|
|
ctx1 := testBuiltinEvalContext(t)
|
|
ctx1.PathValue = []string{"root"}
|
|
ctx1.ProviderInputConfig = cache
|
|
ctx1.ProviderLock = &lock
|
|
|
|
ctx2 := testBuiltinEvalContext(t)
|
|
ctx2.PathValue = []string{"root", "child"}
|
|
ctx2.ProviderInputConfig = cache
|
|
ctx2.ProviderLock = &lock
|
|
|
|
expected1 := map[string]interface{}{"value": "foo"}
|
|
ctx1.SetProviderInput("foo", expected1)
|
|
|
|
expected2 := map[string]interface{}{"value": "bar"}
|
|
ctx2.SetProviderInput("foo", expected2)
|
|
|
|
actual1 := ctx1.ProviderInput("foo")
|
|
actual2 := ctx2.ProviderInput("foo")
|
|
|
|
if !reflect.DeepEqual(actual1, expected1) {
|
|
t.Fatalf("bad: %#v %#v", actual1, expected1)
|
|
}
|
|
if !reflect.DeepEqual(actual2, expected2) {
|
|
t.Fatalf("bad: %#v %#v", actual2, expected2)
|
|
}
|
|
}
|
|
|
|
func testBuiltinEvalContext(t *testing.T) *BuiltinEvalContext {
|
|
return &BuiltinEvalContext{}
|
|
}
|