From ebf4413e9568b0227b9a5ea93109a874e0562bdc Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 23 Jun 2017 10:13:03 -0400 Subject: [PATCH] add named named state delete+create-delete test This ensures that we don't leave any conflicting state artifacts preventing the recreation of a named state. --- backend/testing.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/backend/testing.go b/backend/testing.go index 936f1ddfa..f8546b309 100644 --- a/backend/testing.go +++ b/backend/testing.go @@ -187,6 +187,24 @@ func testBackendStates(t *testing.T, b Backend) { t.Fatal("expected error") } + // Create and delete the foo state again. + // Make sure that there are no leftover artifacts from a deleted state + // preventing re-creation. + foo, err = b.State("foo") + if err != nil { + t.Fatalf("error: %s", err) + } + if err := foo.RefreshState(); err != nil { + t.Fatalf("bad: %s", err) + } + if v := foo.State(); v.HasResources() { + t.Fatalf("should be empty: %s", v) + } + // and delete it again + if err := b.DeleteState("foo"); err != nil { + t.Fatalf("err: %s", err) + } + // Verify deletion { states, err := b.States()