terraform: Update a few tests for new provider FQNs

These will now use "default" provider addresses, rather than "legacy"
ones, so that they can cooperate with the rest of Terraform that has been
updated to no longer use legacy provider addresses.
This commit is contained in:
Martin Atkins 2020-04-06 09:50:37 -07:00
parent 3e3d8f6764
commit e404074bf6
3 changed files with 11 additions and 14 deletions

View File

@ -5789,7 +5789,7 @@ resource "aws_instance" "foo" {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"child"}`),
},
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`),
)
state.EnsureModule(addrs.RootModuleInstance.Child("mod", addrs.IntKey(1))).SetResourceInstanceCurrent(
mustResourceInstanceAddr("aws_instance.foo").Resource,
@ -5797,18 +5797,16 @@ resource "aws_instance" "foo" {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"child"}`),
},
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
mustProviderConfig(`provider["registry.terraform.io/hashicorp/aws"]`),
)
p := testProvider("aws")
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[addrs.Provider]providers.Factory{
addrs.NewLegacyProvider("aws"): testProviderFuncFixed(p),
},
),
Providers: map[addrs.Provider]providers.Factory{
addrs.NewDefaultProvider("aws"): testProviderFuncFixed(p),
},
State: state,
})

View File

@ -1452,11 +1452,9 @@ resource "aws_instance" "foo" {
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[addrs.Provider]providers.Factory{
addrs.NewLegacyProvider("aws"): testProviderFuncFixed(p),
},
),
Providers: map[addrs.Provider]providers.Factory{
addrs.NewDefaultProvider("aws"): testProviderFuncFixed(p),
},
})
diags := ctx.Validate()

View File

@ -4,6 +4,7 @@ import (
"strings"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/states"
)
@ -62,7 +63,7 @@ provider["registry.terraform.io/hashicorp/test"] (close) - *terraform.graphNodeC
test_object.foo[1] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
test_object.foo[2] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
root - *terraform.nodeCloseModule
provider["registry.terraform.io/-/test"] (close) - *terraform.graphNodeCloseProvider
provider["registry.terraform.io/hashicorp/test"] (close) - *terraform.graphNodeCloseProvider
test_object.foo - *terraform.nodeExpandRefreshableManagedResource
provider["registry.terraform.io/hashicorp/test"] - *terraform.NodeApplyableProvider
test_object.foo[0] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstanceObject
@ -73,6 +74,6 @@ test_object.foo[2] (deposed 00000001) - *terraform.NodePlanDeposedResourceInstan
provider["registry.terraform.io/hashicorp/test"] - *terraform.NodeApplyableProvider
`)
if expected != actual {
t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected)
t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s\ndiff:\n%s", actual, expected, cmp.Diff(expected, actual))
}
}