Add -var test.

This commit is contained in:
Luke Kysow
2018-06-18 10:28:58 +01:00
parent a162b36b94
commit de5c4061bd
3 changed files with 51 additions and 3 deletions

View File

@@ -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)

View File

@@ -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
```

View File

@@ -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: <computed>
Plan: 1 to add, 0 to change, 0 to destroy.
```
* To **discard** this plan click [here](lock-url).