From 42febd5d146054667f0b4934eef1dd50d8dece73 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 18 Sep 2018 11:34:19 -0700 Subject: [PATCH] core: Fix testContext2Apply_destroyDependsOn, and similar These tests were relying on the full InstanceInfo we used to give to providers, but the new API doesn't do that and so we will instead lean on the ID from the state to recognize the apply ordering. --- terraform/context_apply_test.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index 844e583f2..eeb488068 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -1283,10 +1283,10 @@ func testContext2Apply_destroyDependsOn(t *testing.T) { var actual []string var actualLock sync.Mutex p.ApplyFn = func( - info *InstanceInfo, _ *InstanceState, _ *InstanceDiff) (*InstanceState, error) { + _ *InstanceInfo, is *InstanceState, _ *InstanceDiff) (*InstanceState, error) { actualLock.Lock() defer actualLock.Unlock() - actual = append(actual, info.Id) + actual = append(actual, is.ID) return nil, nil } @@ -1310,9 +1310,9 @@ func testContext2Apply_destroyDependsOn(t *testing.T) { t.Fatalf("apply errors: %s", diags.Err()) } - expected := []string{"aws_instance.foo", "aws_instance.bar"} + expected := []string{"foo", "bar"} if !reflect.DeepEqual(actual, expected) { - t.Fatalf("bad: %#v", actual) + t.Fatalf("wrong order\ngot: %#v\nwant: %#v", actual, expected) } } @@ -1363,10 +1363,10 @@ func testContext2Apply_destroyDependsOnStateOnly(t *testing.T) { var actual []string var actualLock sync.Mutex p.ApplyFn = func( - info *InstanceInfo, _ *InstanceState, _ *InstanceDiff) (*InstanceState, error) { + _ *InstanceInfo, is *InstanceState, _ *InstanceDiff) (*InstanceState, error) { actualLock.Lock() defer actualLock.Unlock() - actual = append(actual, info.Id) + actual = append(actual, is.ID) return nil, nil } @@ -1390,9 +1390,9 @@ func testContext2Apply_destroyDependsOnStateOnly(t *testing.T) { t.Fatalf("apply errors: %s", diags.Err()) } - expected := []string{"aws_instance.bar", "aws_instance.foo"} + expected := []string{"bar", "foo"} if !reflect.DeepEqual(actual, expected) { - t.Fatalf("bad: %#v", actual) + t.Fatalf("wrong order\ngot: %#v\nwant: %#v", actual, expected) } } @@ -1443,10 +1443,10 @@ func testContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) { var actual []string var actualLock sync.Mutex p.ApplyFn = func( - info *InstanceInfo, _ *InstanceState, _ *InstanceDiff) (*InstanceState, error) { + _ *InstanceInfo, is *InstanceState, _ *InstanceDiff) (*InstanceState, error) { actualLock.Lock() defer actualLock.Unlock() - actual = append(actual, info.Id) + actual = append(actual, is.ID) return nil, nil } @@ -1470,9 +1470,9 @@ func testContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) { t.Fatalf("apply errors: %s", diags.Err()) } - expected := []string{"aws_instance.bar", "aws_instance.foo"} + expected := []string{"bar", "foo"} if !reflect.DeepEqual(actual, expected) { - t.Fatalf("bad: %#v", actual) + t.Fatalf("wrong order\ngot: %#v\nwant: %#v", actual, expected) } }