diff --git a/server/events_controller_e2e_test.go b/server/events_controller_e2e_test.go index 35795cb3e..a791a89bd 100644 --- a/server/events_controller_e2e_test.go +++ b/server/events_controller_e2e_test.go @@ -68,10 +68,21 @@ func TestGitHubWorkflow(t *testing.T) { }, ExpMergeCommentFile: "exp-output-merge.txt", }, + { + Description: "simple with comment -var", + RepoDir: "simple", + ModifiedFiles: []string{"main.tf"}, + ExpAutoplanCommentFile: "exp-output-autoplan.txt", + CommentAndReplies: []string{ + "atlantis plan -- -var var=overridden", "exp-output-atlantis-plan-var.txt", + "atlantis apply", "exp-output-apply-var.txt", + }, + ExpMergeCommentFile: "exp-output-merge.txt", + }, } for _, c := range cases { - ctrl, vcsClient, githubGetter, atlantisWorkspace := setupE2E(t) t.Run(c.Description, func(t *testing.T) { + ctrl, vcsClient, githubGetter, atlantisWorkspace := setupE2E(t) // Set the repo to be cloned through the testing backdoor. repoDir, cleanup := initializeRepo(t, c.RepoDir) defer cleanup() @@ -100,7 +111,7 @@ func TestGitHubWorkflow(t *testing.T) { w = httptest.NewRecorder() ctrl.Post(w, commentReq) responseContains(t, w, 200, "Processing...") - _, _, atlantisComment := vcsClient.VerifyWasCalled(Twice()).CreateComment(AnyRepo(), AnyInt(), AnyString()).GetCapturedArguments() + _, _, atlantisComment := vcsClient.VerifyWasCalled(Times((i/2)+2)).CreateComment(AnyRepo(), AnyInt(), AnyString()).GetCapturedArguments() exp, err = ioutil.ReadFile(filepath.Join(repoDir, expOutputFile)) Ok(t, err) @@ -115,7 +126,8 @@ func TestGitHubWorkflow(t *testing.T) { w = httptest.NewRecorder() ctrl.Post(w, pullClosedReq) responseContains(t, w, 200, "Pull request cleaned successfully") - _, _, pullClosedComment := vcsClient.VerifyWasCalled(Times(3)).CreateComment(AnyRepo(), AnyInt(), AnyString()).GetCapturedArguments() + numPrevComments := (len(c.CommentAndReplies) / 2) + 1 + _, _, pullClosedComment := vcsClient.VerifyWasCalled(Times(numPrevComments+1)).CreateComment(AnyRepo(), AnyInt(), AnyString()).GetCapturedArguments() exp, err = ioutil.ReadFile(filepath.Join(repoDir, c.ExpMergeCommentFile)) Ok(t, err) Equals(t, string(exp), pullClosedComment) diff --git a/server/testfixtures/test-repos/simple/exp-output-apply-var.txt b/server/testfixtures/test-repos/simple/exp-output-apply-var.txt new file mode 100644 index 000000000..3c58045de --- /dev/null +++ b/server/testfixtures/test-repos/simple/exp-output-apply-var.txt @@ -0,0 +1,13 @@ +Ran Apply in dir: `.` workspace: `default` +```diff +null_resource.simple: Creating... +null_resource.simple: Creation complete after 0s (ID: ******************) + +Apply complete! Resources: 1 added, 0 changed, 0 destroyed. + +Outputs: + +this = overridden + +``` + diff --git a/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-var.txt b/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-var.txt new file mode 100644 index 000000000..15a712c42 --- /dev/null +++ b/server/testfixtures/test-repos/simple/exp-output-atlantis-plan-var.txt @@ -0,0 +1,23 @@ +Ran Plan in dir: `.` workspace: `default` +```diff +Refreshing Terraform state in-memory prior to plan... +The refreshed state will be used to calculate this plan, but will not be +persisted to local or remote state storage. + + +------------------------------------------------------------------------ + +An execution plan has been generated and is shown below. +Resource actions are indicated with the following symbols: + + create + +Terraform will perform the following actions: + ++ null_resource.simple + id: +Plan: 1 to add, 0 to change, 0 to destroy. + +``` + +* To **discard** this plan click [here](lock-url). +