Skip to content

Commit

Permalink
add E2E test for workspace deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Sep 8, 2021
1 parent 16165da commit de1b313
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tfexec/internal/e2etest/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,35 @@ func TestWorkspace_multiple(t *testing.T) {
})
}

func TestWorkspace_deletion(t *testing.T) {
runTest(t, "basic", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
assertWorkspaceList(t, tf, "default")

const testWorkspace = "testws"

t.Run("create and delete workspace", func(t *testing.T) {
err := tf.WorkspaceNew(context.Background(), testWorkspace)
if err != nil {
t.Fatalf("got error creating workspace: %s", err)
}

assertWorkspaceList(t, tf, testWorkspace, testWorkspace)

err = tf.WorkspaceSelect(context.Background(), defaultWorkspace)
if err != nil {
t.Fatalf("got error selecting workspace: %s", err)
}

err = tf.WorkspaceDelete(context.Background(), testWorkspace)
if err != nil {
t.Fatalf("got error deleting workspace: %s", err)
}

assertWorkspaceList(t, tf, defaultWorkspace)
})
})
}

func assertWorkspaceList(t *testing.T, tf *tfexec.Terraform, expectedCurrent string, expectedWorkspaces ...string) {
actualWorkspaces, actualCurrent, err := tf.WorkspaceList(context.Background())
if err != nil {
Expand Down

0 comments on commit de1b313

Please sign in to comment.