fixup provider types in new tests

This commit is contained in:
James Bardin 2020-02-13 16:05:28 -05:00
parent 099806c128
commit b4f06c22fe
3 changed files with 29 additions and 27 deletions

View File

@ -299,7 +299,7 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) {
AttrsJSON: []byte(`{"id":"parent"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.aws_instance.child")},
},
mustProviderConfig("provider.aws"),
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
)
child := state.EnsureModule(addrs.RootModuleInstance.Child("child", addrs.NoKey))
child.SetResourceInstanceCurrent(
@ -308,7 +308,7 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"child"}`),
},
mustProviderConfig("provider.aws"),
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
)
{
@ -1264,7 +1264,7 @@ func testContext2Apply_destroyDependsOn(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"bar"}`),
},
mustProviderConfig("provider.aws"),
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
)
root.SetResourceInstanceCurrent(
mustResourceInstanceAddr("aws_instance.foo").Resource,
@ -1273,7 +1273,7 @@ func testContext2Apply_destroyDependsOn(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("aws_instance.bar")},
},
mustProviderConfig("provider.aws"),
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
)
// Record the order we see Apply
@ -2698,7 +2698,7 @@ func TestContext2Apply_moduleDestroyOrder(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"a"}`),
},
mustProviderConfig("provider.aws"),
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
)
root := state.EnsureModule(addrs.RootModuleInstance)
root.SetResourceInstanceCurrent(
@ -2708,7 +2708,7 @@ func TestContext2Apply_moduleDestroyOrder(t *testing.T) {
AttrsJSON: []byte(`{"id":"b"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.aws_instance.a")},
},
mustProviderConfig("provider.aws"),
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
)
ctx := testContext2(t, &ContextOpts{
@ -8029,7 +8029,7 @@ func TestContext2Apply_targetedDestroyCountDeps(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"i-bcd345"}`),
},
mustProviderConfig("provider.aws"),
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
)
root.SetResourceInstanceCurrent(
mustResourceInstanceAddr("aws_instance.bar").Resource,
@ -8038,7 +8038,7 @@ func TestContext2Apply_targetedDestroyCountDeps(t *testing.T) {
AttrsJSON: []byte(`{"id":"i-abc123"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("aws_instance.foo")},
},
mustProviderConfig("provider.aws"),
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
)
ctx := testContext2(t, &ContextOpts{
@ -9672,7 +9672,7 @@ func TestContext2Apply_destroyWithProviders(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"bar"}`),
},
mustProviderConfig("provider.aws.baz"),
mustProviderConfig(`provider["registry.terraform.io/-/aws"].baz`),
)
ctx := testContext2(t, &ContextOpts{
@ -9692,10 +9692,12 @@ func TestContext2Apply_destroyWithProviders(t *testing.T) {
}
// correct the state
state.Modules["module.mod.module.removed"].Resources["aws_instance.child"].ProviderConfig = addrs.LocalProviderConfig{
LocalName: "aws",
Alias: "bar",
}.Absolute(addrs.RootModuleInstance)
state.Modules["module.mod.module.removed"].Resources["aws_instance.child"].ProviderConfig = addrs.AbsProviderConfig{
Provider: addrs.NewLegacyProvider("aws"),
Alias: "bar",
Module: addrs.RootModuleInstance,
}
if _, diags := ctx.Plan(); diags.HasErrors() {
t.Fatal(diags.Err())
}

View File

@ -266,7 +266,7 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"foo"}`),
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
child.SetResourceInstanceCurrent(
mustResourceInstanceAddr("test_object.B").Resource,
@ -275,7 +275,7 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) {
AttrsJSON: []byte(`{"id":"bar"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.test_object.A")},
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
b := &ApplyGraphBuilder{
@ -370,7 +370,7 @@ func TestApplyGraphBuilder_moduleDestroy(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"foo"}`),
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
modB := state.EnsureModule(addrs.RootModuleInstance.Child("B", addrs.NoKey))
modB.SetResourceInstanceCurrent(
@ -380,7 +380,7 @@ func TestApplyGraphBuilder_moduleDestroy(t *testing.T) {
AttrsJSON: []byte(`{"id":"foo","value":"foo"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("module.A.test_object.foo")},
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
b := &ApplyGraphBuilder{

View File

@ -21,7 +21,7 @@ func TestDestroyEdgeTransformer_basic(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"A"}`),
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
root.SetResourceInstanceCurrent(
mustResourceInstanceAddr("test_object.B").Resource,
@ -30,7 +30,7 @@ func TestDestroyEdgeTransformer_basic(t *testing.T) {
AttrsJSON: []byte(`{"id":"B","test_string":"x"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
if err := (&AttachStateTransformer{State: state}).Transform(&g); err != nil {
t.Fatal(err)
@ -65,7 +65,7 @@ func TestDestroyEdgeTransformer_multi(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"A"}`),
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
root.SetResourceInstanceCurrent(
mustResourceInstanceAddr("test_object.B").Resource,
@ -74,7 +74,7 @@ func TestDestroyEdgeTransformer_multi(t *testing.T) {
AttrsJSON: []byte(`{"id":"B","test_string":"x"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
root.SetResourceInstanceCurrent(
mustResourceInstanceAddr("test_object.C").Resource,
@ -86,7 +86,7 @@ func TestDestroyEdgeTransformer_multi(t *testing.T) {
mustResourceAddr("test_object.B"),
},
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
if err := (&AttachStateTransformer{State: state}).Transform(&g); err != nil {
@ -140,7 +140,7 @@ func TestDestroyEdgeTransformer_module(t *testing.T) {
AttrsJSON: []byte(`{"id":"a"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.test_object.b")},
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
child.SetResourceInstanceCurrent(
mustResourceInstanceAddr("test_object.b").Resource,
@ -148,7 +148,7 @@ func TestDestroyEdgeTransformer_module(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"b","test_string":"x"}`),
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
if err := (&AttachStateTransformer{State: state}).Transform(&g); err != nil {
@ -184,7 +184,7 @@ func TestDestroyEdgeTransformer_moduleOnly(t *testing.T) {
Status: states.ObjectReady,
AttrsJSON: []byte(`{"id":"a"}`),
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
child.SetResourceInstanceCurrent(
mustResourceInstanceAddr("test_object.b").Resource,
@ -193,7 +193,7 @@ func TestDestroyEdgeTransformer_moduleOnly(t *testing.T) {
AttrsJSON: []byte(`{"id":"b","test_string":"x"}`),
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.test_object.a")},
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
child.SetResourceInstanceCurrent(
mustResourceInstanceAddr("test_object.c").Resource,
@ -205,7 +205,7 @@ func TestDestroyEdgeTransformer_moduleOnly(t *testing.T) {
mustResourceAddr("module.child.test_object.b"),
},
},
mustProviderConfig("provider.test"),
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
)
if err := (&AttachStateTransformer{State: state}).Transform(&g); err != nil {