From 54dd127939dccec776492d47e725aab12128d410 Mon Sep 17 00:00:00 2001 From: Denis O Date: Fri, 16 Feb 2024 12:20:47 +0000 Subject: [PATCH] Add tests for auto approve --- test/action_run_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/action_run_test.go b/test/action_run_test.go index b289d82..f4f932e 100644 --- a/test/action_run_test.go +++ b/test/action_run_test.go @@ -32,6 +32,41 @@ func TestOutputPlanIsUsedInApply(t *testing.T) { assert.Contains(t, output, "1 added, 0 changed, 0 destroyed") } +func TestRunAllIsExecuted(t *testing.T) { + t.Parallel() + tag := buildActionImage(t) + fixturePath := prepareFixture(t, "fixture-dependencies-project") + + output := runAction(t, tag, fixturePath, "run-all plan") + assert.Contains(t, output, "1 to add, 0 to change, 0 to destroy") + + output = runAction(t, tag, fixturePath, "run-all apply") + assert.Contains(t, output, "1 to add, 0 to change, 0 to destroy") + + output = runAction(t, tag, fixturePath, "run-all destroy") + assert.Contains(t, output, "0 to add, 0 to change, 1 to destroy") + assert.Contains(t, output, "Destroy complete! Resources: 1 destroyed") +} + +func TestAutoApproveDelete(t *testing.T) { + t.Parallel() + tag := buildActionImage(t) + fixturePath := prepareFixture(t, "fixture-dependencies-project") + + output := runAction(t, tag, fixturePath, "run-all plan -out=plan.out") + assert.Contains(t, output, "1 to add, 0 to change, 0 to destroy") + + output = runAction(t, tag, fixturePath, "run-all apply plan.out") + assert.Contains(t, output, "1 added, 0 changed, 0 destroyed") + + // run destroy with auto-approve + output = runAction(t, tag, fixturePath, "run-all plan -destroy -out=destroy.out") + assert.Contains(t, output, "0 to add, 0 to change, 1 to destroy") + + output = runAction(t, tag, fixturePath, "run-all apply -destroy destroy.out") + assert.Contains(t, output, "Resources: 0 added, 0 changed, 1 destroyed") +} + func runAction(t *testing.T, tag, fixturePath, command string) string { opts := &docker.RunOptions{ EnvironmentVariables: []string{