From 8a87d2ef0980f1124732bc6d58b47027e99cd931 Mon Sep 17 00:00:00 2001 From: Luke Massa Date: Wed, 1 Nov 2023 02:16:34 -0400 Subject: [PATCH] fix: Better determine number of expected comments and webhooks in e2e test (#3907) * fix: Better determine number of expected comments and webhooks in e2e test * Cleanup --- .../events/events_controller_e2e_test.go | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index 93c63df3b..d1e8280f9 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -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", @@ -208,6 +229,7 @@ func TestGitHubWorkflow(t *testing.T) { }, ExpAllowResponseCommentBack: true, ExpParseFailedCount: 1, + ExpNoLocksToDelete: true, }, { Description: "simple with atlantis.yaml", @@ -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++