mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 17:01:04 -06:00
core: Fix tests for EvalConfigProvider
The interface of this eval node has changed for v0.12, now requiring both a provider address and the actual provider object. We also need to give it a working ctx.EvalBlock implementation on the mock EvalContext, so we just use installSimpleEval here to get our simple implementation that just knows how to evaluate constant expressions.
This commit is contained in:
parent
9833d9991d
commit
0a59da418a
@ -49,11 +49,20 @@ func TestEvalConfigProvider_impl(t *testing.T) {
|
||||
func TestEvalConfigProvider(t *testing.T) {
|
||||
config := &configs.Provider{
|
||||
Name: "foo",
|
||||
Config: configs.SynthBody("", map[string]cty.Value{
|
||||
"test_string": cty.StringVal("hello"),
|
||||
}),
|
||||
}
|
||||
provider := mockProviderWithConfigSchema(simpleTestSchema())
|
||||
rp := ResourceProvider(provider)
|
||||
n := &EvalConfigProvider{
|
||||
Addr: addrs.ProviderConfig{Type: "foo"},
|
||||
Config: config,
|
||||
Provider: &rp,
|
||||
}
|
||||
provider := &MockResourceProvider{}
|
||||
n := &EvalConfigProvider{Config: config}
|
||||
|
||||
ctx := &MockEvalContext{ProviderProvider: provider}
|
||||
ctx.installSimpleEval()
|
||||
if _, err := n.Eval(ctx); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
@ -61,8 +70,13 @@ func TestEvalConfigProvider(t *testing.T) {
|
||||
if !ctx.ConfigureProviderCalled {
|
||||
t.Fatal("should be called")
|
||||
}
|
||||
if !reflect.DeepEqual(ctx.ConfigureProviderConfig, config) {
|
||||
t.Fatalf("bad: %#v", ctx.ConfigureProviderConfig)
|
||||
|
||||
gotObj := ctx.ConfigureProviderConfig
|
||||
if !gotObj.Type().HasAttribute("test_string") {
|
||||
t.Fatal("configuration object does not have \"test_string\" attribute")
|
||||
}
|
||||
if got, want := gotObj.GetAttr("test_string"), cty.StringVal("hello"); !got.RawEquals(want) {
|
||||
t.Errorf("wrong configuration value\ngot: %#v\nwant: %#v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user