Skip to content

Commit

Permalink
fix: Better determine number of expected comments and webhooks in e2e…
Browse files Browse the repository at this point in the history
… test (#3907)

* fix: Better determine number of expected comments and webhooks in e2e test

* Cleanup
  • Loading branch information
lukemassa authored Nov 1, 2023
1 parent f519638 commit 8a87d2e
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,28 @@ func TestGitHubWorkflow(t *testing.T) {
ExpAllowResponseCommentBack bool
// ExpParseFailedCount represents how many times test sends invalid commands
ExpParseFailedCount int
// ExpNoLocksToDelete whether we expect that there are no locks at the end to delete
ExpNoLocksToDelete bool
}{
{
Description: "no comment or change",
RepoDir: "simple",
ModifiedFiles: []string{},
Comments: []string{},
ExpReplies: [][]string{},
ExpNoLocksToDelete: true,
},
{
Description: "no comment",
RepoDir: "simple",
ModifiedFiles: []string{"main.tf"},
Comments: []string{},
ExpReplies: [][]string{
{"exp-output-autoplan.txt"},
{"exp-output-merge.txt"},
},
ExpAutoplan: true,
},
{
Description: "simple",
RepoDir: "simple",
Expand Down Expand Up @@ -208,6 +229,7 @@ func TestGitHubWorkflow(t *testing.T) {
},
ExpAllowResponseCommentBack: true,
ExpParseFailedCount: 1,
ExpNoLocksToDelete: true,
},
{
Description: "simple with atlantis.yaml",
Expand Down Expand Up @@ -618,9 +640,13 @@ func TestGitHubWorkflow(t *testing.T) {

// Now we're ready to verify Atlantis made all the comments back (or
// replies) that we expect. We expect each plan to have 1 comment,
// and apply have 1 for each comment plus one for the locks deleted at the
// end.
expNumReplies := len(c.Comments) + 1 - c.ExpParseFailedCount
// and apply have 1 for each comment
expNumReplies := len(c.Comments)

// If there are locks to delete at the end, that will take a comment
if !c.ExpNoLocksToDelete {
expNumReplies++
}

if c.ExpAutoplan {
expNumReplies++
Expand Down

0 comments on commit 8a87d2e

Please sign in to comment.