From 7fe34d45473cf1eafda72648be7679dc1c8f6d84 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 9 Apr 2015 08:21:24 -0500 Subject: [PATCH] providers: check for empty plan after each test step Each acceptance test step plays a Refresh, Plan, Apply for a given config. This adds a follow up Plan and fails the test if it does not come back empty. This will catch issues with perpetual, unresolvable diffs that crop up here and there. This is going to cause a lot of our existing acceptance tests to fail - too many to roll into a single PR. I think the best plan is to land this in master and then fix the failures (each of which should be catching a legitimate provider bug) one by one until we get the provider suites back to green. --- helper/resource/testing.go | 10 ++++++++++ helper/resource/testing_test.go | 2 ++ 2 files changed, 12 insertions(+) diff --git a/helper/resource/testing.go b/helper/resource/testing.go index 90cfc175f..43a59e93c 100644 --- a/helper/resource/testing.go +++ b/helper/resource/testing.go @@ -230,6 +230,16 @@ func testStep( } } + // Verify that Plan is now empty and we don't have a perpetual diff issue + if p, err := ctx.Plan(); err != nil { + return state, fmt.Errorf("Error on follow-up plan: %s", err) + } else { + if p.Diff != nil && !p.Diff.Empty() { + return state, fmt.Errorf( + "After applying this step, the plan was not empty:\n\n%s", p) + } + } + return state, err } diff --git a/helper/resource/testing_test.go b/helper/resource/testing_test.go index cf51c7b22..2f7ed0517 100644 --- a/helper/resource/testing_test.go +++ b/helper/resource/testing_test.go @@ -18,6 +18,8 @@ func init() { func TestTest(t *testing.T) { mp := testProvider() + mp.DiffReturn = nil + mp.ApplyReturn = &terraform.InstanceState{ ID: "foo", }