diff --git a/cmd/server_test.go b/cmd/server_test.go index 572242b7e8..0e518c636b 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -27,7 +27,7 @@ import ( "gopkg.in/yaml.v2" "github.com/runatlantis/atlantis/server" - "github.com/runatlantis/atlantis/server/events/vcs/fixtures" + "github.com/runatlantis/atlantis/server/events/vcs/testdata" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) @@ -427,7 +427,7 @@ func TestExecute_ValidateVCSConfig(t *testing.T) { { "just github app key set", map[string]interface{}{ - GHAppKeyFlag: fixtures.GithubPrivateKey, + GHAppKeyFlag: testdata.GithubPrivateKey, }, true, }, @@ -496,7 +496,7 @@ func TestExecute_ValidateVCSConfig(t *testing.T) { "github app and key set and should be successful", map[string]interface{}{ GHAppIDFlag: "1", - GHAppKeyFlag: fixtures.GithubPrivateKey, + GHAppKeyFlag: testdata.GithubPrivateKey, }, false, }, @@ -631,7 +631,7 @@ func TestExecute_GithubUser(t *testing.T) { func TestExecute_GithubApp(t *testing.T) { t.Log("Should remove the @ from the github username if it's passed.") c := setup(map[string]interface{}{ - GHAppKeyFlag: fixtures.GithubPrivateKey, + GHAppKeyFlag: testdata.GithubPrivateKey, GHAppIDFlag: "1", RepoAllowlistFlag: "*", }, t) diff --git a/server/controllers/events/events_controller_e2e_test.go b/server/controllers/events/events_controller_e2e_test.go index bead7dffb6..0be1944511 100644 --- a/server/controllers/events/events_controller_e2e_test.go +++ b/server/controllers/events/events_controller_e2e_test.go @@ -81,7 +81,7 @@ func TestGitHubWorkflow(t *testing.T) { cases := []struct { Description string - // RepoDir is relative to testfixtures/test-repos. + // RepoDir is relative to testdata/test-repos. RepoDir string // RepoConfigFile is path for atlantis.yaml RepoConfigFile string @@ -592,7 +592,7 @@ func TestSimpleWorkflow_terraformLockFile(t *testing.T) { cases := []struct { Description string - // RepoDir is relative to testfixtures/test-repos. + // RepoDir is relative to testdata/test-repos. RepoDir string // ModifiedFiles are the list of files that have been modified in this // pull request. @@ -664,7 +664,7 @@ func TestSimpleWorkflow_terraformLockFile(t *testing.T) { // Set the repo to be cloned through the testing backdoor. repoDir, headSHA := initializeRepo(t, c.RepoDir) - oldLockFilePath, err := filepath.Abs(filepath.Join("testfixtures", "null_provider_lockfile_old_version")) + oldLockFilePath, err := filepath.Abs(filepath.Join("testdata", "null_provider_lockfile_old_version")) Ok(t, err) oldLockFileContent, err := os.ReadFile(oldLockFilePath) Ok(t, err) @@ -759,7 +759,7 @@ func TestGitHubWorkflowWithPolicyCheck(t *testing.T) { cases := []struct { Description string - // RepoDir is relative to testfixtures/test-repos. + // RepoDir is relative to testdata/test-repos. RepoDir string // ModifiedFiles are the list of files that have been modified in this // pull request. @@ -1330,7 +1330,7 @@ func (w *mockWebhookSender) Send(log logging.SimpleLogging, result webhooks.Appl } func GitHubCommentEvent(t *testing.T, comment string) *http.Request { - requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubIssueCommentEvent.json")) + requestJSON, err := os.ReadFile(filepath.Join("testdata", "githubIssueCommentEvent.json")) Ok(t, err) escapedComment, err := json.Marshal(comment) Ok(t, err) @@ -1343,7 +1343,7 @@ func GitHubCommentEvent(t *testing.T, comment string) *http.Request { } func GitHubPullRequestOpenedEvent(t *testing.T, headSHA string) *http.Request { - requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubPullRequestOpenedEvent.json")) + requestJSON, err := os.ReadFile(filepath.Join("testdata", "githubPullRequestOpenedEvent.json")) Ok(t, err) // Replace sha with expected sha. requestJSONStr := strings.Replace(string(requestJSON), "c31fd9ea6f557ad2ea659944c3844a059b83bc5d", headSHA, -1) @@ -1355,7 +1355,7 @@ func GitHubPullRequestOpenedEvent(t *testing.T, headSHA string) *http.Request { } func GitHubPullRequestClosedEvent(t *testing.T) *http.Request { - requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubPullRequestClosedEvent.json")) + requestJSON, err := os.ReadFile(filepath.Join("testdata", "githubPullRequestClosedEvent.json")) Ok(t, err) req, err := http.NewRequest("POST", "/events", bytes.NewBuffer(requestJSON)) Ok(t, err) @@ -1396,12 +1396,12 @@ func GitHubPullRequestParsed(headSHA string) *github.PullRequest { // absRepoPath returns the absolute path to the test repo under dir repoDir. func absRepoPath(t *testing.T, repoDir string) string { - path, err := filepath.Abs(filepath.Join("testfixtures", "test-repos", repoDir)) + path, err := filepath.Abs(filepath.Join("testdata", "test-repos", repoDir)) Ok(t, err) return path } -// initializeRepo copies the repo data from testfixtures and initializes a new +// initializeRepo copies the repo data from testdata and initializes a new // git repo in a temp directory. It returns that directory and a function // to run in a defer that will delete the dir. // The purpose of this function is to create a real git repository with a branch diff --git a/server/controllers/events/events_controller_test.go b/server/controllers/events/events_controller_test.go index 5722627d42..28b9d0d9ff 100644 --- a/server/controllers/events/events_controller_test.go +++ b/server/controllers/events/events_controller_test.go @@ -207,7 +207,7 @@ func TestPost_GitlabCommentNotAllowlisted(t *testing.T) { RepoAllowlistChecker: &events.RepoAllowlistChecker{}, VCSClient: vcsClient, } - requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "gitlabMergeCommentEvent_notAllowlisted.json")) + requestJSON, err := os.ReadFile(filepath.Join("testdata", "gitlabMergeCommentEvent_notAllowlisted.json")) Ok(t, err) req, _ := http.NewRequest("GET", "", bytes.NewBuffer(requestJSON)) req.Header.Set(gitlabHeader, "Note Hook") @@ -239,7 +239,7 @@ func TestPost_GitlabCommentNotAllowlistedWithSilenceErrors(t *testing.T) { VCSClient: vcsClient, SilenceAllowlistErrors: true, } - requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "gitlabMergeCommentEvent_notAllowlisted.json")) + requestJSON, err := os.ReadFile(filepath.Join("testdata", "gitlabMergeCommentEvent_notAllowlisted.json")) Ok(t, err) req, _ := http.NewRequest("GET", "", bytes.NewBuffer(requestJSON)) req.Header.Set(gitlabHeader, "Note Hook") @@ -270,7 +270,7 @@ func TestPost_GithubCommentNotAllowlisted(t *testing.T) { RepoAllowlistChecker: &events.RepoAllowlistChecker{}, VCSClient: vcsClient, } - requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubIssueCommentEvent_notAllowlisted.json")) + requestJSON, err := os.ReadFile(filepath.Join("testdata", "githubIssueCommentEvent_notAllowlisted.json")) Ok(t, err) req, _ := http.NewRequest("GET", "", bytes.NewBuffer(requestJSON)) req.Header.Set("Content-Type", "application/json") @@ -303,7 +303,7 @@ func TestPost_GithubCommentNotAllowlistedWithSilenceErrors(t *testing.T) { VCSClient: vcsClient, SilenceAllowlistErrors: true, } - requestJSON, err := os.ReadFile(filepath.Join("testfixtures", "githubIssueCommentEvent_notAllowlisted.json")) + requestJSON, err := os.ReadFile(filepath.Join("testdata", "githubIssueCommentEvent_notAllowlisted.json")) Ok(t, err) req, _ := http.NewRequest("GET", "", bytes.NewBuffer(requestJSON)) req.Header.Set("Content-Type", "application/json") @@ -709,7 +709,7 @@ func TestPost_BBServerPullClosed(t *testing.T) { } // Build HTTP request. - requestBytes, err := os.ReadFile(filepath.Join("testfixtures", "bb-server-pull-deleted-event.json")) + requestBytes, err := os.ReadFile(filepath.Join("testdata", "bb-server-pull-deleted-event.json")) // Replace the eventKey field with our event type. requestJSON := strings.Replace(string(requestBytes), `"eventKey":"pr:deleted",`, fmt.Sprintf(`"eventKey":"%s",`, c.header), -1) Ok(t, err) diff --git a/server/controllers/events/testfixtures/bb-server-pull-deleted-event.json b/server/controllers/events/testdata/bb-server-pull-deleted-event.json similarity index 100% rename from server/controllers/events/testfixtures/bb-server-pull-deleted-event.json rename to server/controllers/events/testdata/bb-server-pull-deleted-event.json diff --git a/server/controllers/events/testfixtures/githubIssueCommentEvent.json b/server/controllers/events/testdata/githubIssueCommentEvent.json similarity index 100% rename from server/controllers/events/testfixtures/githubIssueCommentEvent.json rename to server/controllers/events/testdata/githubIssueCommentEvent.json diff --git a/server/controllers/events/testfixtures/githubIssueCommentEvent_notAllowlisted.json b/server/controllers/events/testdata/githubIssueCommentEvent_notAllowlisted.json similarity index 100% rename from server/controllers/events/testfixtures/githubIssueCommentEvent_notAllowlisted.json rename to server/controllers/events/testdata/githubIssueCommentEvent_notAllowlisted.json diff --git a/server/controllers/events/testfixtures/githubPullRequestClosedEvent.json b/server/controllers/events/testdata/githubPullRequestClosedEvent.json similarity index 100% rename from server/controllers/events/testfixtures/githubPullRequestClosedEvent.json rename to server/controllers/events/testdata/githubPullRequestClosedEvent.json diff --git a/server/controllers/events/testfixtures/githubPullRequestOpenedEvent.json b/server/controllers/events/testdata/githubPullRequestOpenedEvent.json similarity index 100% rename from server/controllers/events/testfixtures/githubPullRequestOpenedEvent.json rename to server/controllers/events/testdata/githubPullRequestOpenedEvent.json diff --git a/server/controllers/events/testfixtures/gitlabMergeCommentEvent_notAllowlisted.json b/server/controllers/events/testdata/gitlabMergeCommentEvent_notAllowlisted.json similarity index 100% rename from server/controllers/events/testfixtures/gitlabMergeCommentEvent_notAllowlisted.json rename to server/controllers/events/testdata/gitlabMergeCommentEvent_notAllowlisted.json diff --git a/server/controllers/events/testfixtures/gitlabMergeCommentEvent_shouldIgnore.json b/server/controllers/events/testdata/gitlabMergeCommentEvent_shouldIgnore.json similarity index 100% rename from server/controllers/events/testfixtures/gitlabMergeCommentEvent_shouldIgnore.json rename to server/controllers/events/testdata/gitlabMergeCommentEvent_shouldIgnore.json diff --git a/server/controllers/events/testfixtures/null_provider_lockfile_old_version b/server/controllers/events/testdata/null_provider_lockfile_old_version similarity index 100% rename from server/controllers/events/testfixtures/null_provider_lockfile_old_version rename to server/controllers/events/testdata/null_provider_lockfile_old_version diff --git a/server/controllers/events/testfixtures/test-repos/automerge/atlantis.yaml b/server/controllers/events/testdata/test-repos/automerge/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/automerge/atlantis.yaml rename to server/controllers/events/testdata/test-repos/automerge/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/automerge/dir1/main.tf b/server/controllers/events/testdata/test-repos/automerge/dir1/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/automerge/dir1/main.tf rename to server/controllers/events/testdata/test-repos/automerge/dir1/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/automerge/dir2/main.tf b/server/controllers/events/testdata/test-repos/automerge/dir2/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/automerge/dir2/main.tf rename to server/controllers/events/testdata/test-repos/automerge/dir2/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir1.txt b/server/controllers/events/testdata/test-repos/automerge/exp-output-apply-dir1.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir1.txt rename to server/controllers/events/testdata/test-repos/automerge/exp-output-apply-dir1.txt diff --git a/server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir2.txt b/server/controllers/events/testdata/test-repos/automerge/exp-output-apply-dir2.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/automerge/exp-output-apply-dir2.txt rename to server/controllers/events/testdata/test-repos/automerge/exp-output-apply-dir2.txt diff --git a/server/controllers/events/testfixtures/test-repos/automerge/exp-output-automerge.txt b/server/controllers/events/testdata/test-repos/automerge/exp-output-automerge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/automerge/exp-output-automerge.txt rename to server/controllers/events/testdata/test-repos/automerge/exp-output-automerge.txt diff --git a/server/controllers/events/testfixtures/test-repos/automerge/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/automerge/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/automerge/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/automerge/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/automerge/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/automerge/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/automerge/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/automerge/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-multiple-project/atlantis.yaml b/server/controllers/events/testdata/test-repos/import-multiple-project/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-multiple-project/atlantis.yaml rename to server/controllers/events/testdata/test-repos/import-multiple-project/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/import-multiple-project/dir1/main.tf b/server/controllers/events/testdata/test-repos/import-multiple-project/dir1/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-multiple-project/dir1/main.tf rename to server/controllers/events/testdata/test-repos/import-multiple-project/dir1/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/import-multiple-project/dir2/main.tf b/server/controllers/events/testdata/test-repos/import-multiple-project/dir2/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-multiple-project/dir2/main.tf rename to server/controllers/events/testdata/test-repos/import-multiple-project/dir2/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-import-dummy1.txt b/server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-import-dummy1.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-import-dummy1.txt rename to server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-import-dummy1.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-import-multiple-projects.txt b/server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-import-multiple-projects.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-import-multiple-projects.txt rename to server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-import-multiple-projects.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-plan-again.txt b/server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-plan-again.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-multiple-project/exp-output-plan-again.txt rename to server/controllers/events/testdata/test-repos/import-multiple-project/exp-output-plan-again.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-import-count.txt b/server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-import-count.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-import-count.txt rename to server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-import-count.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-import-foreach.txt b/server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-import-foreach.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-import-foreach.txt rename to server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-import-foreach.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-plan-again.txt b/server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-plan-again.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project-var/exp-output-plan-again.txt rename to server/controllers/events/testdata/test-repos/import-single-project-var/exp-output-plan-again.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project-var/main.tf b/server/controllers/events/testdata/test-repos/import-single-project-var/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project-var/main.tf rename to server/controllers/events/testdata/test-repos/import-single-project-var/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-apply-no-projects.txt b/server/controllers/events/testdata/test-repos/import-single-project/exp-output-apply-no-projects.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-apply-no-projects.txt rename to server/controllers/events/testdata/test-repos/import-single-project/exp-output-apply-no-projects.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/import-single-project/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/import-single-project/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-import-dummy1.txt b/server/controllers/events/testdata/test-repos/import-single-project/exp-output-import-dummy1.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-import-dummy1.txt rename to server/controllers/events/testdata/test-repos/import-single-project/exp-output-import-dummy1.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-import-dummy2.txt b/server/controllers/events/testdata/test-repos/import-single-project/exp-output-import-dummy2.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-import-dummy2.txt rename to server/controllers/events/testdata/test-repos/import-single-project/exp-output-import-dummy2.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/import-single-project/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/import-single-project/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-plan-again.txt b/server/controllers/events/testdata/test-repos/import-single-project/exp-output-plan-again.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project/exp-output-plan-again.txt rename to server/controllers/events/testdata/test-repos/import-single-project/exp-output-plan-again.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-single-project/main.tf b/server/controllers/events/testdata/test-repos/import-single-project/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-single-project/main.tf rename to server/controllers/events/testdata/test-repos/import-single-project/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/import-workspace/atlantis.yaml b/server/controllers/events/testdata/test-repos/import-workspace/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-workspace/atlantis.yaml rename to server/controllers/events/testdata/test-repos/import-workspace/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/import-workspace/dir1/main.tf b/server/controllers/events/testdata/test-repos/import-workspace/dir1/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-workspace/dir1/main.tf rename to server/controllers/events/testdata/test-repos/import-workspace/dir1/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/import-workspace/exp-output-import-dir1-ops-dummy1.txt b/server/controllers/events/testdata/test-repos/import-workspace/exp-output-import-dir1-ops-dummy1.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-workspace/exp-output-import-dir1-ops-dummy1.txt rename to server/controllers/events/testdata/test-repos/import-workspace/exp-output-import-dir1-ops-dummy1.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-workspace/exp-output-import-dir1-ops-dummy2.txt b/server/controllers/events/testdata/test-repos/import-workspace/exp-output-import-dir1-ops-dummy2.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-workspace/exp-output-import-dir1-ops-dummy2.txt rename to server/controllers/events/testdata/test-repos/import-workspace/exp-output-import-dir1-ops-dummy2.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-workspace/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/import-workspace/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-workspace/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/import-workspace/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/import-workspace/exp-output-plan.txt b/server/controllers/events/testdata/test-repos/import-workspace/exp-output-plan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/import-workspace/exp-output-plan.txt rename to server/controllers/events/testdata/test-repos/import-workspace/exp-output-plan.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/atlantis.yaml b/server/controllers/events/testdata/test-repos/modules-yaml/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/atlantis.yaml rename to server/controllers/events/testdata/test-repos/modules-yaml/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-production.txt b/server/controllers/events/testdata/test-repos/modules-yaml/exp-output-apply-production.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-production.txt rename to server/controllers/events/testdata/test-repos/modules-yaml/exp-output-apply-production.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-staging.txt b/server/controllers/events/testdata/test-repos/modules-yaml/exp-output-apply-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-apply-staging.txt rename to server/controllers/events/testdata/test-repos/modules-yaml/exp-output-apply-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/modules-yaml/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/modules-yaml/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge-all-dirs.txt b/server/controllers/events/testdata/test-repos/modules-yaml/exp-output-merge-all-dirs.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge-all-dirs.txt rename to server/controllers/events/testdata/test-repos/modules-yaml/exp-output-merge-all-dirs.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge-only-staging.txt b/server/controllers/events/testdata/test-repos/modules-yaml/exp-output-merge-only-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge-only-staging.txt rename to server/controllers/events/testdata/test-repos/modules-yaml/exp-output-merge-only-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/modules-yaml/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/modules-yaml/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-plan-production.txt b/server/controllers/events/testdata/test-repos/modules-yaml/exp-output-plan-production.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-plan-production.txt rename to server/controllers/events/testdata/test-repos/modules-yaml/exp-output-plan-production.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-plan-staging.txt b/server/controllers/events/testdata/test-repos/modules-yaml/exp-output-plan-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/exp-output-plan-staging.txt rename to server/controllers/events/testdata/test-repos/modules-yaml/exp-output-plan-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/modules/null/main.tf b/server/controllers/events/testdata/test-repos/modules-yaml/modules/null/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/modules/null/main.tf rename to server/controllers/events/testdata/test-repos/modules-yaml/modules/null/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/production/main.tf b/server/controllers/events/testdata/test-repos/modules-yaml/production/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/production/main.tf rename to server/controllers/events/testdata/test-repos/modules-yaml/production/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/modules-yaml/staging/main.tf b/server/controllers/events/testdata/test-repos/modules-yaml/staging/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules-yaml/staging/main.tf rename to server/controllers/events/testdata/test-repos/modules-yaml/staging/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-production.txt b/server/controllers/events/testdata/test-repos/modules/exp-output-apply-production.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-production.txt rename to server/controllers/events/testdata/test-repos/modules/exp-output-apply-production.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-staging.txt b/server/controllers/events/testdata/test-repos/modules/exp-output-apply-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/exp-output-apply-staging.txt rename to server/controllers/events/testdata/test-repos/modules/exp-output-apply-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt b/server/controllers/events/testdata/test-repos/modules/exp-output-autoplan-only-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/exp-output-autoplan-only-staging.txt rename to server/controllers/events/testdata/test-repos/modules/exp-output-autoplan-only-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-merge-all-dirs.txt b/server/controllers/events/testdata/test-repos/modules/exp-output-merge-all-dirs.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/exp-output-merge-all-dirs.txt rename to server/controllers/events/testdata/test-repos/modules/exp-output-merge-all-dirs.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-merge-only-staging.txt b/server/controllers/events/testdata/test-repos/modules/exp-output-merge-only-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/exp-output-merge-only-staging.txt rename to server/controllers/events/testdata/test-repos/modules/exp-output-merge-only-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/modules/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/modules/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-production.txt b/server/controllers/events/testdata/test-repos/modules/exp-output-plan-production.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-production.txt rename to server/controllers/events/testdata/test-repos/modules/exp-output-plan-production.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-staging.txt b/server/controllers/events/testdata/test-repos/modules/exp-output-plan-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/exp-output-plan-staging.txt rename to server/controllers/events/testdata/test-repos/modules/exp-output-plan-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/modules/modules/null/main.tf b/server/controllers/events/testdata/test-repos/modules/modules/null/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/modules/null/main.tf rename to server/controllers/events/testdata/test-repos/modules/modules/null/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/modules/production/main.tf b/server/controllers/events/testdata/test-repos/modules/production/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/production/main.tf rename to server/controllers/events/testdata/test-repos/modules/production/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/modules/staging/main.tf b/server/controllers/events/testdata/test-repos/modules/staging/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/modules/staging/main.tf rename to server/controllers/events/testdata/test-repos/modules/staging/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/atlantis.yaml b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/atlantis.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply-failed.txt b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-apply-failed.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply-failed.txt rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-apply-failed.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply.txt b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-apply.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-apply.txt rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-apply.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-approve-policies.txt b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-approve-policies.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-approve-policies.txt rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-approve-policies.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-auto-policy-check.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/main.tf b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/main.tf rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/policies/policy.rego b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/policies/policy.rego similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/policies/policy.rego rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/policies/policy.rego diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/repos.yaml b/server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/repos.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-apply-reqs/repos.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-apply-reqs/repos.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/atlantis.yaml b/server/controllers/events/testdata/test-repos/policy-checks-diff-owner/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/atlantis.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-diff-owner/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-apply-failed.txt b/server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-apply-failed.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-apply-failed.txt rename to server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-apply-failed.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-approve-policies.txt b/server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-approve-policies.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-approve-policies.txt rename to server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-approve-policies.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt b/server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt rename to server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-auto-policy-check.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/policy-checks-diff-owner/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/main.tf b/server/controllers/events/testdata/test-repos/policy-checks-diff-owner/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/main.tf rename to server/controllers/events/testdata/test-repos/policy-checks-diff-owner/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/policies/policy.rego b/server/controllers/events/testdata/test-repos/policy-checks-diff-owner/policies/policy.rego similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/policies/policy.rego rename to server/controllers/events/testdata/test-repos/policy-checks-diff-owner/policies/policy.rego diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/repos.yaml b/server/controllers/events/testdata/test-repos/policy-checks-diff-owner/repos.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-diff-owner/repos.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-diff-owner/repos.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/atlantis.yaml b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/atlantis.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply-failed.txt b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-apply-failed.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply-failed.txt rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-apply-failed.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply.txt b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-apply.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-apply.txt rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-apply.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-approve-policies.txt b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-approve-policies.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-approve-policies.txt rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-approve-policies.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-auto-policy-check.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/main.tf b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/main.tf rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/policies/policy.rego b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/policies/policy.rego similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/policies/policy.rego rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/policies/policy.rego diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/repos.yaml b/server/controllers/events/testdata/test-repos/policy-checks-extra-args/repos.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-extra-args/repos.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-extra-args/repos.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/atlantis.yaml b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/atlantis.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/dir1/main.tf b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/dir1/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/dir1/main.tf rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/dir1/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/dir2/main.tf b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/dir2/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/dir2/main.tf rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/dir2/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-apply.txt b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-apply.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-apply.txt rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-apply.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-approve-policies.txt b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-approve-policies.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-approve-policies.txt rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-approve-policies.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-auto-policy-check.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/policies/policy.rego b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/policies/policy.rego similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/policies/policy.rego rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/policies/policy.rego diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/repos.yaml b/server/controllers/events/testdata/test-repos/policy-checks-multi-projects/repos.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-multi-projects/repos.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-multi-projects/repos.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/atlantis.yaml b/server/controllers/events/testdata/test-repos/policy-checks-success-silent/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/atlantis.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-success-silent/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/exp-output-apply.txt b/server/controllers/events/testdata/test-repos/policy-checks-success-silent/exp-output-apply.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/exp-output-apply.txt rename to server/controllers/events/testdata/test-repos/policy-checks-success-silent/exp-output-apply.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/policy-checks-success-silent/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/policy-checks-success-silent/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/policy-checks-success-silent/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/policy-checks-success-silent/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/main.tf b/server/controllers/events/testdata/test-repos/policy-checks-success-silent/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/main.tf rename to server/controllers/events/testdata/test-repos/policy-checks-success-silent/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/policies/policy.rego b/server/controllers/events/testdata/test-repos/policy-checks-success-silent/policies/policy.rego similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/policies/policy.rego rename to server/controllers/events/testdata/test-repos/policy-checks-success-silent/policies/policy.rego diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/repos.yaml b/server/controllers/events/testdata/test-repos/policy-checks-success-silent/repos.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks-success-silent/repos.yaml rename to server/controllers/events/testdata/test-repos/policy-checks-success-silent/repos.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/atlantis.yaml b/server/controllers/events/testdata/test-repos/policy-checks/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/atlantis.yaml rename to server/controllers/events/testdata/test-repos/policy-checks/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-apply-failed.txt b/server/controllers/events/testdata/test-repos/policy-checks/exp-output-apply-failed.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-apply-failed.txt rename to server/controllers/events/testdata/test-repos/policy-checks/exp-output-apply-failed.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-apply.txt b/server/controllers/events/testdata/test-repos/policy-checks/exp-output-apply.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-apply.txt rename to server/controllers/events/testdata/test-repos/policy-checks/exp-output-apply.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-approve-policies.txt b/server/controllers/events/testdata/test-repos/policy-checks/exp-output-approve-policies.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-approve-policies.txt rename to server/controllers/events/testdata/test-repos/policy-checks/exp-output-approve-policies.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt b/server/controllers/events/testdata/test-repos/policy-checks/exp-output-auto-policy-check.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-auto-policy-check.txt rename to server/controllers/events/testdata/test-repos/policy-checks/exp-output-auto-policy-check.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/policy-checks/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/policy-checks/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/policy-checks/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/policy-checks/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/main.tf b/server/controllers/events/testdata/test-repos/policy-checks/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/main.tf rename to server/controllers/events/testdata/test-repos/policy-checks/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/policies/policy.rego b/server/controllers/events/testdata/test-repos/policy-checks/policies/policy.rego similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/policies/policy.rego rename to server/controllers/events/testdata/test-repos/policy-checks/policies/policy.rego diff --git a/server/controllers/events/testfixtures/test-repos/policy-checks/repos.yaml b/server/controllers/events/testdata/test-repos/policy-checks/repos.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/policy-checks/repos.yaml rename to server/controllers/events/testdata/test-repos/policy-checks/repos.yaml diff --git a/server/controllers/events/testfixtures/test-repos/repo-config-file/exp-output-apply.txt b/server/controllers/events/testdata/test-repos/repo-config-file/exp-output-apply.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/repo-config-file/exp-output-apply.txt rename to server/controllers/events/testdata/test-repos/repo-config-file/exp-output-apply.txt diff --git a/server/controllers/events/testfixtures/test-repos/repo-config-file/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/repo-config-file/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/repo-config-file/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/repo-config-file/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/repo-config-file/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/repo-config-file/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/repo-config-file/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/repo-config-file/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/repo-config-file/infrastructure/custom-name-atlantis.yaml b/server/controllers/events/testdata/test-repos/repo-config-file/infrastructure/custom-name-atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/repo-config-file/infrastructure/custom-name-atlantis.yaml rename to server/controllers/events/testdata/test-repos/repo-config-file/infrastructure/custom-name-atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/repo-config-file/infrastructure/production/main.tf b/server/controllers/events/testdata/test-repos/repo-config-file/infrastructure/production/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/repo-config-file/infrastructure/production/main.tf rename to server/controllers/events/testdata/test-repos/repo-config-file/infrastructure/production/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/repo-config-file/infrastructure/staging/main.tf b/server/controllers/events/testdata/test-repos/repo-config-file/infrastructure/staging/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/repo-config-file/infrastructure/staging/main.tf rename to server/controllers/events/testdata/test-repos/repo-config-file/infrastructure/staging/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/atlantis.yaml b/server/controllers/events/testdata/test-repos/server-side-cfg/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/server-side-cfg/atlantis.yaml rename to server/controllers/events/testdata/test-repos/server-side-cfg/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt b/server/controllers/events/testdata/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt rename to server/controllers/events/testdata/test-repos/server-side-cfg/exp-output-apply-default-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt b/server/controllers/events/testdata/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt rename to server/controllers/events/testdata/test-repos/server-side-cfg/exp-output-apply-staging-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/server-side-cfg/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/server-side-cfg/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/server-side-cfg/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/server-side-cfg/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/server-side-cfg/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/main.tf b/server/controllers/events/testdata/test-repos/server-side-cfg/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/server-side-cfg/main.tf rename to server/controllers/events/testdata/test-repos/server-side-cfg/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/server-side-cfg/repos.yaml b/server/controllers/events/testdata/test-repos/server-side-cfg/repos.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/server-side-cfg/repos.yaml rename to server/controllers/events/testdata/test-repos/server-side-cfg/repos.yaml diff --git a/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/simple-with-lockfile/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/simple-with-lockfile/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-plan.txt b/server/controllers/events/testdata/test-repos/simple-with-lockfile/exp-output-plan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-with-lockfile/exp-output-plan.txt rename to server/controllers/events/testdata/test-repos/simple-with-lockfile/exp-output-plan.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-with-lockfile/main.tf b/server/controllers/events/testdata/test-repos/simple-with-lockfile/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-with-lockfile/main.tf rename to server/controllers/events/testdata/test-repos/simple-with-lockfile/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/atlantis.yaml b/server/controllers/events/testdata/test-repos/simple-yaml/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-yaml/atlantis.yaml rename to server/controllers/events/testdata/test-repos/simple-yaml/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt b/server/controllers/events/testdata/test-repos/simple-yaml/exp-output-apply-all.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-all.txt rename to server/controllers/events/testdata/test-repos/simple-yaml/exp-output-apply-all.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-default.txt b/server/controllers/events/testdata/test-repos/simple-yaml/exp-output-apply-default.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-default.txt rename to server/controllers/events/testdata/test-repos/simple-yaml/exp-output-apply-default.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-locked.txt b/server/controllers/events/testdata/test-repos/simple-yaml/exp-output-apply-locked.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-locked.txt rename to server/controllers/events/testdata/test-repos/simple-yaml/exp-output-apply-locked.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-staging.txt b/server/controllers/events/testdata/test-repos/simple-yaml/exp-output-apply-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-apply-staging.txt rename to server/controllers/events/testdata/test-repos/simple-yaml/exp-output-apply-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/simple-yaml/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/simple-yaml/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/simple-yaml/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-yaml/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/simple-yaml/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/main.tf b/server/controllers/events/testdata/test-repos/simple-yaml/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-yaml/main.tf rename to server/controllers/events/testdata/test-repos/simple-yaml/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/simple-yaml/staging.tfvars b/server/controllers/events/testdata/test-repos/simple-yaml/staging.tfvars similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple-yaml/staging.tfvars rename to server/controllers/events/testdata/test-repos/simple-yaml/staging.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-allow-command-unknown-import.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-allow-command-unknown-import.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-allow-command-unknown-import.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-allow-command-unknown-import.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-all.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-apply-var-all.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-all.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-apply-var-all.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-default-workspace.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-apply-var-default-workspace.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-default-workspace.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-apply-var-default-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-new-workspace.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-apply-var-new-workspace.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var-new-workspace.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-apply-var-new-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-apply-var.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-apply-var.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-apply-var.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-apply.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-apply.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-apply.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-apply.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-atlantis-plan-new-workspace.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-atlantis-plan-var-overridden.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-atlantis-plan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-atlantis-plan.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-atlantis-plan.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-auto-policy-check.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-auto-policy-check.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-auto-policy-check.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-auto-policy-check.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-merge-workspaces.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-merge-workspaces.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-merge-workspaces.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-merge-workspaces.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/simple/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/simple/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/simple/main.tf b/server/controllers/events/testdata/test-repos/simple/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/simple/main.tf rename to server/controllers/events/testdata/test-repos/simple/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/atlantis.yaml b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/atlantis.yaml rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.backend.tfvars b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/default.backend.tfvars similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.backend.tfvars rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/default.backend.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.tfvars b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/default.tfvars similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/default.tfvars rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/default.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-default.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-apply-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-default.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/exp-output-plan-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/main.tf b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/main.tf rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.backend.tfvars b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/staging.backend.tfvars similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.backend.tfvars rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/staging.backend.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.tfvars b/server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/staging.tfvars similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml-no-autoplan/staging.tfvars rename to server/controllers/events/testdata/test-repos/tfvars-yaml-no-autoplan/staging.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/atlantis.yaml b/server/controllers/events/testdata/test-repos/tfvars-yaml/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/atlantis.yaml rename to server/controllers/events/testdata/test-repos/tfvars-yaml/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/default.backend.tfvars b/server/controllers/events/testdata/test-repos/tfvars-yaml/default.backend.tfvars similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/default.backend.tfvars rename to server/controllers/events/testdata/test-repos/tfvars-yaml/default.backend.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/default.tfvars b/server/controllers/events/testdata/test-repos/tfvars-yaml/default.tfvars similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/default.tfvars rename to server/controllers/events/testdata/test-repos/tfvars-yaml/default.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt b/server/controllers/events/testdata/test-repos/tfvars-yaml/exp-output-apply-default.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-default.txt rename to server/controllers/events/testdata/test-repos/tfvars-yaml/exp-output-apply-default.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt b/server/controllers/events/testdata/test-repos/tfvars-yaml/exp-output-apply-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-apply-staging.txt rename to server/controllers/events/testdata/test-repos/tfvars-yaml/exp-output-apply-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt b/server/controllers/events/testdata/test-repos/tfvars-yaml/exp-output-autoplan.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-autoplan.txt rename to server/controllers/events/testdata/test-repos/tfvars-yaml/exp-output-autoplan.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/tfvars-yaml/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/tfvars-yaml/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/main.tf b/server/controllers/events/testdata/test-repos/tfvars-yaml/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/main.tf rename to server/controllers/events/testdata/test-repos/tfvars-yaml/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/staging.backend.tfvars b/server/controllers/events/testdata/test-repos/tfvars-yaml/staging.backend.tfvars similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/staging.backend.tfvars rename to server/controllers/events/testdata/test-repos/tfvars-yaml/staging.backend.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/tfvars-yaml/staging.tfvars b/server/controllers/events/testdata/test-repos/tfvars-yaml/staging.tfvars similarity index 100% rename from server/controllers/events/testfixtures/test-repos/tfvars-yaml/staging.tfvars rename to server/controllers/events/testdata/test-repos/tfvars-yaml/staging.tfvars diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/atlantis.yaml b/server/controllers/events/testdata/test-repos/workspace-parallel-yaml/atlantis.yaml similarity index 100% rename from server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/atlantis.yaml rename to server/controllers/events/testdata/test-repos/workspace-parallel-yaml/atlantis.yaml diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt b/server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt rename to server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-apply-all-production.txt diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt b/server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt rename to server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-apply-all-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt b/server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt rename to server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-autoplan-production.txt diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt b/server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt rename to server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-autoplan-staging.txt diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-merge.txt b/server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-merge.txt similarity index 100% rename from server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/exp-output-merge.txt rename to server/controllers/events/testdata/test-repos/workspace-parallel-yaml/exp-output-merge.txt diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/production/main.tf b/server/controllers/events/testdata/test-repos/workspace-parallel-yaml/production/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/production/main.tf rename to server/controllers/events/testdata/test-repos/workspace-parallel-yaml/production/main.tf diff --git a/server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/staging/main.tf b/server/controllers/events/testdata/test-repos/workspace-parallel-yaml/staging/main.tf similarity index 100% rename from server/controllers/events/testfixtures/test-repos/workspace-parallel-yaml/staging/main.tf rename to server/controllers/events/testdata/test-repos/workspace-parallel-yaml/staging/main.tf diff --git a/server/controllers/templates/web_templates.go b/server/controllers/templates/web_templates.go index 6dc2a567a0..103114e622 100644 --- a/server/controllers/templates/web_templates.go +++ b/server/controllers/templates/web_templates.go @@ -242,7 +242,6 @@ type LockDetailData struct { PullRequestLink string LockedBy string Workspace string - Time time.Time AtlantisVersion string // CleanedBasePath is the path Atlantis is accessible at externally. If // not using a path-based proxy, this will be an empty string. Never ends diff --git a/server/controllers/templates/web_templates_test.go b/server/controllers/templates/web_templates_test.go new file mode 100644 index 0000000000..091f3db275 --- /dev/null +++ b/server/controllers/templates/web_templates_test.go @@ -0,0 +1,79 @@ +package templates + +import ( + "io" + "testing" + "time" + + . "github.com/runatlantis/atlantis/testing" +) + +func TestIndexTemplate(t *testing.T) { + err := IndexTemplate.Execute(io.Discard, IndexData{ + Locks: []LockIndexData{ + { + LockPath: "lock path", + RepoFullName: "repo full name", + PullNum: 1, + Path: "path", + Workspace: "workspace", + Time: time.Now(), + TimeFormatted: "02-01-2006 15:04:05", + }, + }, + ApplyLock: ApplyLockData{ + Locked: true, + Time: time.Now(), + TimeFormatted: "02-01-2006 15:04:05", + }, + AtlantisVersion: "v0.0.0", + CleanedBasePath: "/path", + }) + Ok(t, err) +} + +func TestLockTemplate(t *testing.T) { + err := LockTemplate.Execute(io.Discard, LockDetailData{ + LockKeyEncoded: "lock key encoded", + LockKey: "lock key", + PullRequestLink: "https://example.com", + LockedBy: "locked by", + Workspace: "workspace", + AtlantisVersion: "v0.0.0", + CleanedBasePath: "/path", + RepoOwner: "repo owner", + RepoName: "repo name", + }) + Ok(t, err) +} + +func TestProjectJobsTemplate(t *testing.T) { + err := ProjectJobsTemplate.Execute(io.Discard, ProjectJobData{ + AtlantisVersion: "v0.0.0", + ProjectPath: "project path", + CleanedBasePath: "/path", + }) + Ok(t, err) +} + +func TestProjectJobsErrorTemplate(t *testing.T) { + err := ProjectJobsTemplate.Execute(io.Discard, ProjectJobsError{ + AtlantisVersion: "v0.0.0", + ProjectPath: "project path", + CleanedBasePath: "/path", + }) + Ok(t, err) +} + +func TestGithubAppSetupTemplate(t *testing.T) { + err := GithubAppSetupTemplate.Execute(io.Discard, GithubSetupData{ + Target: "target", + Manifest: "manifest", + ID: 1, + Key: "key", + WebhookSecret: "webhook secret", + URL: "https://example.com", + CleanedBasePath: "/path", + }) + Ok(t, err) +} diff --git a/server/events/apply_command_runner_test.go b/server/events/apply_command_runner_test.go index d26ccf5cc6..d87e323ef4 100644 --- a/server/events/apply_command_runner_test.go +++ b/server/events/apply_command_runner_test.go @@ -10,7 +10,7 @@ import ( "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/models/fixtures" + "github.com/runatlantis/atlantis/server/events/models/testdata" "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/metrics" ) @@ -53,23 +53,23 @@ func TestApplyCommandRunner_IsLocked(t *testing.T) { pull := &github.PullRequest{ State: github.String("open"), } - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState, Num: fixtures.Pull.Num} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) ctx := &command.Context{ - User: fixtures.User, + User: testdata.User, Log: logging.NewNoopLogger(t), Scope: scopeNull, Pull: modelPull, - HeadRepo: fixtures.GithubRepo, + HeadRepo: testdata.GithubRepo, Trigger: command.CommentTrigger, } When(applyLockChecker.CheckApplyLock()).ThenReturn(locking.ApplyCommandLock{Locked: c.ApplyLocked}, c.ApplyLockError) applyCommandRunner.Run(ctx, &events.CommentCommand{Name: command.Apply}) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, c.ExpComment, "apply") + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, modelPull.Num, c.ExpComment, "apply") }) } } diff --git a/server/events/approve_policies_command_runner_test.go b/server/events/approve_policies_command_runner_test.go index 1f86f5b7c5..8db1ad1216 100644 --- a/server/events/approve_policies_command_runner_test.go +++ b/server/events/approve_policies_command_runner_test.go @@ -9,7 +9,7 @@ import ( "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/models/fixtures" + "github.com/runatlantis/atlantis/server/events/models/testdata" "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/metrics" ) @@ -32,7 +32,7 @@ func TestApproveCommandRunner_IsOwner(t *testing.T) { }, { Description: "When user is an owner, approval succeeds", - OwnerUsers: []string{fixtures.User.Username}, + OwnerUsers: []string{testdata.User.Username}, OwnerTeams: []string{}, ExpComment: "Approved Policies for 1 projects:\n\n1. dir: `` workspace: ``", }, @@ -52,7 +52,7 @@ func TestApproveCommandRunner_IsOwner(t *testing.T) { }, { Description: "When user is an owner but not a team member, approval succeeds", - OwnerUsers: []string{fixtures.User.Username}, + OwnerUsers: []string{testdata.User.Username}, OwnerTeams: []string{"SomeTeam"}, UserTeams: []string{"SomeOtherTeam"}, ExpComment: "Approved Policies for 1 projects:\n\n1. dir: `` workspace: ``", @@ -65,14 +65,14 @@ func TestApproveCommandRunner_IsOwner(t *testing.T) { scopeNull, _, _ := metrics.NewLoggingScope(logger, "atlantis") - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState, Num: fixtures.Pull.Num} + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} ctx := &command.Context{ - User: fixtures.User, + User: testdata.User, Log: logging.NewNoopLogger(t), Scope: scopeNull, Pull: modelPull, - HeadRepo: fixtures.GithubRepo, + HeadRepo: testdata.GithubRepo, Trigger: command.CommentTrigger, } @@ -87,11 +87,11 @@ func TestApproveCommandRunner_IsOwner(t *testing.T) { }, }, }, nil) - When(vcsClient.GetTeamNamesForUser(fixtures.GithubRepo, fixtures.User)).ThenReturn(c.UserTeams, nil) + When(vcsClient.GetTeamNamesForUser(testdata.GithubRepo, testdata.User)).ThenReturn(c.UserTeams, nil) approvePoliciesCommandRunner.Run(ctx, &events.CommentCommand{Name: command.ApprovePolicies}) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, c.ExpComment, "approve_policies") + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, modelPull.Num, c.ExpComment, "approve_policies") }) } } diff --git a/server/events/command_runner_test.go b/server/events/command_runner_test.go index 1d4cace7b3..edc99356b6 100644 --- a/server/events/command_runner_test.go +++ b/server/events/command_runner_test.go @@ -33,7 +33,7 @@ import ( "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/models/fixtures" + "github.com/runatlantis/atlantis/server/events/models/testdata" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" vcsmatchers "github.com/runatlantis/atlantis/server/events/vcs/mocks/matchers" . "github.com/runatlantis/atlantis/testing" @@ -250,8 +250,8 @@ func setup(t *testing.T, options ...func(testConfig *TestConfig)) *vcsmocks.Mock func TestRunCommentCommand_LogPanics(t *testing.T) { t.Log("if there is a panic it is commented back on the pull request") vcsClient := setup(t) - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenPanic("panic test - if you're seeing this in a test failure this isn't the failing test") - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, 1, &events.CommentCommand{Name: command.Plan}) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenPanic("panic test - if you're seeing this in a test failure this isn't the failing test") + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, nil, testdata.User, 1, &events.CommentCommand{Name: command.Plan}) _, _, comment, _ := vcsClient.VerifyWasCalledOnce().CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()).GetCapturedArguments() Assert(t, strings.Contains(comment, "Error: goroutine panic"), fmt.Sprintf("comment should be about a goroutine panic but was %q", comment)) } @@ -259,28 +259,28 @@ func TestRunCommentCommand_LogPanics(t *testing.T) { func TestRunCommentCommand_GithubPullErr(t *testing.T) { t.Log("if getting the github pull request fails an error should be logged") vcsClient := setup(t) - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(nil, errors.New("err")) - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, nil) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, fixtures.Pull.Num, "`Error: making pull request API call to GitHub: err`", "") + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(nil, errors.New("err")) + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, nil, testdata.User, testdata.Pull.Num, nil) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, testdata.Pull.Num, "`Error: making pull request API call to GitHub: err`", "") } func TestRunCommentCommand_GitlabMergeRequestErr(t *testing.T) { t.Log("if getting the gitlab merge request fails an error should be logged") vcsClient := setup(t) - When(gitlabGetter.GetMergeRequest(fixtures.GitlabRepo.FullName, fixtures.Pull.Num)).ThenReturn(nil, errors.New("err")) - ch.RunCommentCommand(fixtures.GitlabRepo, &fixtures.GitlabRepo, nil, fixtures.User, fixtures.Pull.Num, nil) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GitlabRepo, fixtures.Pull.Num, "`Error: making merge request API call to GitLab: err`", "") + When(gitlabGetter.GetMergeRequest(testdata.GitlabRepo.FullName, testdata.Pull.Num)).ThenReturn(nil, errors.New("err")) + ch.RunCommentCommand(testdata.GitlabRepo, &testdata.GitlabRepo, nil, testdata.User, testdata.Pull.Num, nil) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GitlabRepo, testdata.Pull.Num, "`Error: making merge request API call to GitLab: err`", "") } func TestRunCommentCommand_GithubPullParseErr(t *testing.T) { t.Log("if parsing the returned github pull request fails an error should be logged") vcsClient := setup(t) var pull github.PullRequest - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) - When(eventParsing.ParseGithubPull(&pull)).ThenReturn(fixtures.Pull, fixtures.GithubRepo, fixtures.GitlabRepo, errors.New("err")) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(testdata.Pull, testdata.GithubRepo, testdata.GitlabRepo, errors.New("err")) - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, nil) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, fixtures.Pull.Num, "`Error: extracting required fields from comment data: err`", "") + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, nil, testdata.User, testdata.Pull.Num, nil) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, testdata.Pull.Num, "`Error: extracting required fields from comment data: err`", "") } func TestRunCommentCommand_TeamAllowListChecker(t *testing.T) { @@ -290,15 +290,15 @@ func TestRunCommentCommand_TeamAllowListChecker(t *testing.T) { ch.TeamAllowlistChecker = nil var pull github.PullRequest modelPull := models.PullRequest{ - BaseRepo: fixtures.GithubRepo, + BaseRepo: testdata.GithubRepo, State: models.OpenPullState, } - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) - When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) - vcsClient.VerifyWasCalled(Never()).GetTeamNamesForUser(fixtures.GithubRepo, fixtures.User) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:", "plan") + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) + vcsClient.VerifyWasCalled(Never()).GetTeamNamesForUser(testdata.GithubRepo, testdata.User) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:", "plan") }) t.Run("no rules", func(t *testing.T) { @@ -307,15 +307,15 @@ func TestRunCommentCommand_TeamAllowListChecker(t *testing.T) { ch.TeamAllowlistChecker = &events.TeamAllowlistChecker{} var pull github.PullRequest modelPull := models.PullRequest{ - BaseRepo: fixtures.GithubRepo, + BaseRepo: testdata.GithubRepo, State: models.OpenPullState, } - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) - When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) - vcsClient.VerifyWasCalled(Never()).GetTeamNamesForUser(fixtures.GithubRepo, fixtures.User) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:", "plan") + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) + vcsClient.VerifyWasCalled(Never()).GetTeamNamesForUser(testdata.GithubRepo, testdata.User) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:", "plan") }) } @@ -328,19 +328,19 @@ func TestRunCommentCommand_ForkPRDisabled(t *testing.T) { ch.SilenceForkPRErrors = false var pull github.PullRequest modelPull := models.PullRequest{ - BaseRepo: fixtures.GithubRepo, + BaseRepo: testdata.GithubRepo, State: models.OpenPullState, } - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) - headRepo := fixtures.GithubRepo + headRepo := testdata.GithubRepo headRepo.FullName = "forkrepo/atlantis" headRepo.Owner = "forkrepo" When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, headRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) commentMessage := fmt.Sprintf("Atlantis commands can't be run on fork pull requests. To enable, set --%s or, to disable this message, set --%s", ch.AllowForkPRsFlag, ch.SilenceForkPRErrorsFlag) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, commentMessage, "") + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, modelPull.Num, commentMessage, "") } func TestRunCommentCommand_ForkPRDisabled_SilenceEnabled(t *testing.T) { @@ -349,15 +349,15 @@ func TestRunCommentCommand_ForkPRDisabled_SilenceEnabled(t *testing.T) { ch.AllowForkPRs = false // by default it's false so don't need to reset ch.SilenceForkPRErrors = true var pull github.PullRequest - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) - headRepo := fixtures.GithubRepo + headRepo := testdata.GithubRepo headRepo.FullName = "forkrepo/atlantis" headRepo.Owner = "forkrepo" When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, headRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) } @@ -366,11 +366,11 @@ func TestRunCommentCommandPlan_NoProjects_SilenceEnabled(t *testing.T) { vcsClient := setup(t) planCommandRunner.SilenceNoProjects = true var pull github.PullRequest - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) - When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount( matchers.AnyModelsRepo(), @@ -387,11 +387,11 @@ func TestRunCommentCommandApply_NoProjects_SilenceEnabled(t *testing.T) { vcsClient := setup(t) applyCommandRunner.SilenceNoProjects = true var pull github.PullRequest - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) - When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Apply}) + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Apply}) vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount( matchers.AnyModelsRepo(), @@ -408,11 +408,11 @@ func TestRunCommentCommandApprovePolicy_NoProjects_SilenceEnabled(t *testing.T) vcsClient := setup(t) approvePoliciesCommandRunner.SilenceNoProjects = true var pull github.PullRequest - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) - When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies}) + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies}) vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount( matchers.AnyModelsRepo(), @@ -429,11 +429,11 @@ func TestRunCommentCommandUnlock_NoProjects_SilenceEnabled(t *testing.T) { vcsClient := setup(t) unlockCommandRunner.SilenceNoProjects = true var pull github.PullRequest - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) - When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Unlock}) + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Unlock}) vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) } @@ -445,12 +445,12 @@ func TestRunCommentCommand_DisableApplyAllDisabled(t *testing.T) { pull := &github.PullRequest{ State: github.String("open"), } - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState, Num: fixtures.Pull.Num} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, modelPull.Num, &events.CommentCommand{Name: command.Apply}) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "**Error:** Running `atlantis apply` without flags is disabled. You must specify which project to apply via the `-d `, `-w ` or `-p ` flags.", "apply") + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, modelPull.Num, &events.CommentCommand{Name: command.Apply}) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, modelPull.Num, "**Error:** Running `atlantis apply` without flags is disabled. You must specify which project to apply via the `-d `, `-w ` or `-p ` flags.", "apply") } func TestRunCommentCommand_DisableDisableAutoplan(t *testing.T) { @@ -469,7 +469,7 @@ func TestRunCommentCommand_DisableDisableAutoplan(t *testing.T) { }, }, nil) - ch.RunAutoplanCommand(fixtures.GithubRepo, fixtures.GithubRepo, fixtures.Pull, fixtures.User) + ch.RunAutoplanCommand(testdata.GithubRepo, testdata.GithubRepo, testdata.Pull, testdata.User) projectCommandBuilder.VerifyWasCalled(Never()).BuildAutoplanCommands(matchers.AnyPtrToCommandContext()) } @@ -480,12 +480,12 @@ func TestRunCommentCommand_ClosedPull(t *testing.T) { pull := &github.PullRequest{ State: github.String("closed"), } - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.ClosedPullState, Num: fixtures.Pull.Num} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.ClosedPullState, Num: testdata.Pull.Num} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "Atlantis commands can't be run on closed pull requests", "") + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, modelPull.Num, "Atlantis commands can't be run on closed pull requests", "") } func TestRunCommentCommand_MatchedBranch(t *testing.T) { @@ -497,12 +497,12 @@ func TestRunCommentCommand_MatchedBranch(t *testing.T) { BranchRegex: regexp.MustCompile("^main$"), }) var pull github.PullRequest - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, BaseBranch: "main"} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) - When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, BaseBranch: "main"} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:", "plan") + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, modelPull.Num, "Ran Plan for 0 projects:", "plan") } func TestRunCommentCommand_UnmatchedBranch(t *testing.T) { @@ -514,11 +514,11 @@ func TestRunCommentCommand_UnmatchedBranch(t *testing.T) { BranchRegex: regexp.MustCompile("^main$"), }) var pull github.PullRequest - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, BaseBranch: "foo"} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(&pull, nil) - When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, BaseBranch: "foo"} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(&pull, nil) + When(eventParsing.ParseGithubPull(&pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) vcsClient.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) } @@ -547,14 +547,14 @@ func TestRunUnlockCommand_VCSComment(t *testing.T) { pull := &github.PullRequest{ State: tc.prState, } - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState, Num: fixtures.Pull.Num} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Unlock}) + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Unlock}) - deleteLockCommand.VerifyWasCalledOnce().DeleteLocksByPull(fixtures.GithubRepo.FullName, fixtures.Pull.Num) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, fixtures.Pull.Num, "All Atlantis locks for this PR have been unlocked and plans discarded", "unlock") + deleteLockCommand.VerifyWasCalledOnce().DeleteLocksByPull(testdata.GithubRepo.FullName, testdata.Pull.Num) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, testdata.Pull.Num, "All Atlantis locks for this PR have been unlocked and plans discarded", "unlock") }) } } @@ -567,14 +567,14 @@ func TestRunUnlockCommandFail_VCSComment(t *testing.T) { pull := &github.PullRequest{ State: github.String("open"), } - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState, Num: fixtures.Pull.Num} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) - When(deleteLockCommand.DeleteLocksByPull(fixtures.GithubRepo.FullName, fixtures.Pull.Num)).ThenReturn(0, errors.New("err")) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) + When(deleteLockCommand.DeleteLocksByPull(testdata.GithubRepo.FullName, testdata.Pull.Num)).ThenReturn(0, errors.New("err")) - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Unlock}) + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Unlock}) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, fixtures.Pull.Num, "Failed to delete PR locks", "unlock") + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, testdata.Pull.Num, "Failed to delete PR locks", "unlock") } func TestRunAutoplanCommand_DeletePlans(t *testing.T) { @@ -598,10 +598,10 @@ func TestRunAutoplanCommand_DeletePlans(t *testing.T) { }, nil) When(projectCommandRunner.Plan(matchers.AnyCommandProjectContext())).ThenReturn(command.ProjectResult{PlanSuccess: &models.PlanSuccess{}}) When(workingDir.GetPullDir(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn(tmp, nil) - fixtures.Pull.BaseRepo = fixtures.GithubRepo - ch.RunAutoplanCommand(fixtures.GithubRepo, fixtures.GithubRepo, fixtures.Pull, fixtures.User) + testdata.Pull.BaseRepo = testdata.GithubRepo + ch.RunAutoplanCommand(testdata.GithubRepo, testdata.GithubRepo, testdata.Pull, testdata.User) pendingPlanFinder.VerifyWasCalledOnce().DeletePlans(tmp) - lockingLocker.VerifyWasCalledOnce().UnlockByPull(fixtures.Pull.BaseRepo.FullName, fixtures.Pull.Num) + lockingLocker.VerifyWasCalledOnce().UnlockByPull(testdata.Pull.BaseRepo.FullName, testdata.Pull.Num) } func TestRunGenericPlanCommand_DeletePlans(t *testing.T) { @@ -617,13 +617,13 @@ func TestRunGenericPlanCommand_DeletePlans(t *testing.T) { When(projectCommandRunner.Plan(matchers.AnyCommandProjectContext())).ThenReturn(command.ProjectResult{PlanSuccess: &models.PlanSuccess{}}) When(workingDir.GetPullDir(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn(tmp, nil) pull := &github.PullRequest{State: github.String("open")} - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState, Num: fixtures.Pull.Num} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) - fixtures.Pull.BaseRepo = fixtures.GithubRepo - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) + testdata.Pull.BaseRepo = testdata.GithubRepo + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) pendingPlanFinder.VerifyWasCalledOnce().DeletePlans(tmp) - lockingLocker.VerifyWasCalledOnce().UnlockByPull(fixtures.Pull.BaseRepo.FullName, fixtures.Pull.Num) + lockingLocker.VerifyWasCalledOnce().UnlockByPull(testdata.Pull.BaseRepo.FullName, testdata.Pull.Num) } func TestRunSpecificPlanCommandDoesnt_DeletePlans(t *testing.T) { @@ -638,8 +638,8 @@ func TestRunSpecificPlanCommandDoesnt_DeletePlans(t *testing.T) { When(projectCommandRunner.Plan(matchers.AnyCommandProjectContext())).ThenReturn(command.ProjectResult{PlanSuccess: &models.PlanSuccess{}}) When(workingDir.GetPullDir(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn(tmp, nil) - fixtures.Pull.BaseRepo = fixtures.GithubRepo - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan, ProjectName: "default"}) + testdata.Pull.BaseRepo = testdata.GithubRepo + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan, ProjectName: "default"}) pendingPlanFinder.VerifyWasCalled(Never()).DeletePlans(tmp) } @@ -686,8 +686,8 @@ func TestRunAutoplanCommandWithError_DeletePlans(t *testing.T) { When(workingDir.GetPullDir(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())). ThenReturn(tmp, nil) - fixtures.Pull.BaseRepo = fixtures.GithubRepo - ch.RunAutoplanCommand(fixtures.GithubRepo, fixtures.GithubRepo, fixtures.Pull, fixtures.User) + testdata.Pull.BaseRepo = testdata.GithubRepo + ch.RunAutoplanCommand(testdata.GithubRepo, testdata.GithubRepo, testdata.Pull, testdata.User) // gets called twice: the first time before the plan starts, the second time after the plan errors pendingPlanFinder.VerifyWasCalled(Times(2)).DeletePlans(tmp) @@ -710,13 +710,13 @@ func TestRunGenericPlanCommand_DiscardApprovals(t *testing.T) { When(projectCommandRunner.Plan(matchers.AnyCommandProjectContext())).ThenReturn(command.ProjectResult{PlanSuccess: &models.PlanSuccess{}}) When(workingDir.GetPullDir(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())).ThenReturn(tmp, nil) pull := &github.PullRequest{State: github.String("open")} - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState, Num: fixtures.Pull.Num} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) - fixtures.Pull.BaseRepo = fixtures.GithubRepo - ch.RunCommentCommand(fixtures.GithubRepo, nil, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Plan}) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) + testdata.Pull.BaseRepo = testdata.GithubRepo + ch.RunCommentCommand(testdata.GithubRepo, nil, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Plan}) pendingPlanFinder.VerifyWasCalledOnce().DeletePlans(tmp) - lockingLocker.VerifyWasCalledOnce().UnlockByPull(fixtures.Pull.BaseRepo.FullName, fixtures.Pull.Num) + lockingLocker.VerifyWasCalledOnce().UnlockByPull(testdata.Pull.BaseRepo.FullName, testdata.Pull.Num) vcsClient.VerifyWasCalledOnce().DiscardReviews(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest()) } @@ -737,12 +737,12 @@ func TestFailedApprovalCreatesFailedStatusUpdate(t *testing.T) { } modelPull := models.PullRequest{ - BaseRepo: fixtures.GithubRepo, + BaseRepo: testdata.GithubRepo, State: models.OpenPullState, - Num: fixtures.Pull.Num, + Num: testdata.Pull.Num, } - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) When(projectCommandBuilder.BuildApprovePoliciesCommands(matchers.AnyPtrToCommandContext(), matchers.AnyPtrToEventsCommentCommand())).ThenReturn([]command.ProjectContext{ { @@ -753,9 +753,9 @@ func TestFailedApprovalCreatesFailedStatusUpdate(t *testing.T) { }, }, nil) - When(workingDir.GetPullDir(fixtures.GithubRepo, fixtures.Pull)).ThenReturn(tmp, nil) + When(workingDir.GetPullDir(testdata.GithubRepo, testdata.Pull)).ThenReturn(tmp, nil) - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &fixtures.Pull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies}) + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, &testdata.Pull, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies}) commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount( matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest(), @@ -782,25 +782,25 @@ func TestApprovedPoliciesUpdateFailedPolicyStatus(t *testing.T) { } modelPull := models.PullRequest{ - BaseRepo: fixtures.GithubRepo, + BaseRepo: testdata.GithubRepo, State: models.OpenPullState, - Num: fixtures.Pull.Num, + Num: testdata.Pull.Num, } - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) When(projectCommandBuilder.BuildApprovePoliciesCommands(matchers.AnyPtrToCommandContext(), matchers.AnyPtrToEventsCommentCommand())).ThenReturn([]command.ProjectContext{ { CommandName: command.ApprovePolicies, PolicySets: valid.PolicySets{ Owners: valid.PolicyOwners{ - Users: []string{fixtures.User.Username}, + Users: []string{testdata.User.Username}, }, }, }, }, nil) - When(workingDir.GetPullDir(fixtures.GithubRepo, fixtures.Pull)).ThenReturn(tmp, nil) + When(workingDir.GetPullDir(testdata.GithubRepo, testdata.Pull)).ThenReturn(tmp, nil) When(projectCommandRunner.ApprovePolicies(matchers.AnyCommandProjectContext())).Then(func(_ []Param) ReturnValues { return ReturnValues{ command.ProjectResult{ @@ -810,7 +810,7 @@ func TestApprovedPoliciesUpdateFailedPolicyStatus(t *testing.T) { } }) - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &fixtures.Pull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies}) + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, &testdata.Pull, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.ApprovePolicies}) commitUpdater.VerifyWasCalledOnce().UpdateCombinedCount( matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest(), @@ -837,12 +837,12 @@ func TestApplyMergeablityWhenPolicyCheckFails(t *testing.T) { } modelPull := models.PullRequest{ - BaseRepo: fixtures.GithubRepo, + BaseRepo: testdata.GithubRepo, State: models.OpenPullState, - Num: fixtures.Pull.Num, + Num: testdata.Pull.Num, } - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) _, _ = boltDB.UpdatePullWithResults(modelPull, []command.ProjectResult{ { @@ -854,7 +854,7 @@ func TestApplyMergeablityWhenPolicyCheckFails(t *testing.T) { }, }) - When(ch.VCSClient.PullIsMergeable(fixtures.GithubRepo, modelPull, "atlantis-test")).ThenReturn(true, nil) + When(ch.VCSClient.PullIsMergeable(testdata.GithubRepo, modelPull, "atlantis-test")).ThenReturn(true, nil) When(projectCommandBuilder.BuildApplyCommands(matchers.AnyPtrToCommandContext(), matchers.AnyPtrToEventsCommentCommand())).Then(func(args []Param) ReturnValues { return ReturnValues{ @@ -871,8 +871,8 @@ func TestApplyMergeablityWhenPolicyCheckFails(t *testing.T) { } }) - When(workingDir.GetPullDir(fixtures.GithubRepo, modelPull)).ThenReturn(tmp, nil) - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &modelPull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Apply}) + When(workingDir.GetPullDir(testdata.GithubRepo, modelPull)).ThenReturn(tmp, nil) + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, &modelPull, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Apply}) } func TestApplyWithAutoMerge_VSCMerge(t *testing.T) { @@ -882,9 +882,9 @@ func TestApplyWithAutoMerge_VSCMerge(t *testing.T) { pull := &github.PullRequest{ State: github.String("open"), } - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState} - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(pull, nil) - When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, fixtures.GithubRepo, nil) + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState} + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(pull, nil) + When(eventParsing.ParseGithubPull(pull)).ThenReturn(modelPull, modelPull.BaseRepo, testdata.GithubRepo, nil) autoMerger.GlobalAutomerge = true defer func() { autoMerger.GlobalAutomerge = false }() @@ -892,7 +892,7 @@ func TestApplyWithAutoMerge_VSCMerge(t *testing.T) { DeleteSourceBranchOnMerge: false, } - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Apply}) + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, nil, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Apply}) vcsClient.VerifyWasCalledOnce().MergePull(modelPull, pullOptions) } @@ -907,8 +907,8 @@ func TestRunApply_DiscardedProjects(t *testing.T) { Ok(t, err) dbUpdater.Backend = boltDB applyCommandRunner.Backend = boltDB - pull := fixtures.Pull - pull.BaseRepo = fixtures.GithubRepo + pull := testdata.Pull + pull.BaseRepo = testdata.GithubRepo _, err = boltDB.UpdatePullWithResults(pull, []command.ProjectResult{ { Command: command.Plan, @@ -925,11 +925,11 @@ func TestRunApply_DiscardedProjects(t *testing.T) { ghPull := &github.PullRequest{ State: github.String("open"), } - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenReturn(ghPull, nil) - When(eventParsing.ParseGithubPull(ghPull)).ThenReturn(pull, pull.BaseRepo, fixtures.GithubRepo, nil) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenReturn(ghPull, nil) + When(eventParsing.ParseGithubPull(ghPull)).ThenReturn(pull, pull.BaseRepo, testdata.GithubRepo, nil) When(workingDir.GetPullDir(matchers.AnyModelsRepo(), matchers.AnyModelsPullRequest())). ThenReturn(tmp, nil) - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, &pull, fixtures.User, fixtures.Pull.Num, &events.CommentCommand{Name: command.Apply}) + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, &pull, testdata.User, testdata.Pull.Num, &events.CommentCommand{Name: command.Apply}) vcsClient.VerifyWasCalled(Never()).MergePull(matchers.AnyModelsPullRequest(), vcsmatchers.AnyModelsPullRequestOptions()) } @@ -938,16 +938,16 @@ func TestRunCommentCommand_DrainOngoing(t *testing.T) { t.Log("if drain is ongoing then a message should be displayed") vcsClient := setup(t) drainer.ShutdownBlocking() - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, nil) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, fixtures.Pull.Num, "Atlantis server is shutting down, please try again later.", "") + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, nil, testdata.User, testdata.Pull.Num, nil) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, testdata.Pull.Num, "Atlantis server is shutting down, please try again later.", "") } func TestRunCommentCommand_DrainNotOngoing(t *testing.T) { t.Log("if drain is not ongoing then remove ongoing operation must be called even if panic occurred") setup(t) - When(githubGetter.GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num)).ThenPanic("panic test - if you're seeing this in a test failure this isn't the failing test") - ch.RunCommentCommand(fixtures.GithubRepo, &fixtures.GithubRepo, nil, fixtures.User, fixtures.Pull.Num, nil) - githubGetter.VerifyWasCalledOnce().GetPullRequest(fixtures.GithubRepo, fixtures.Pull.Num) + When(githubGetter.GetPullRequest(testdata.GithubRepo, testdata.Pull.Num)).ThenPanic("panic test - if you're seeing this in a test failure this isn't the failing test") + ch.RunCommentCommand(testdata.GithubRepo, &testdata.GithubRepo, nil, testdata.User, testdata.Pull.Num, nil) + githubGetter.VerifyWasCalledOnce().GetPullRequest(testdata.GithubRepo, testdata.Pull.Num) Equals(t, 0, drainer.GetStatus().InProgressOps) } @@ -955,16 +955,16 @@ func TestRunAutoplanCommand_DrainOngoing(t *testing.T) { t.Log("if drain is ongoing then a message should be displayed") vcsClient := setup(t) drainer.ShutdownBlocking() - ch.RunAutoplanCommand(fixtures.GithubRepo, fixtures.GithubRepo, fixtures.Pull, fixtures.User) - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, fixtures.Pull.Num, "Atlantis server is shutting down, please try again later.", "plan") + ch.RunAutoplanCommand(testdata.GithubRepo, testdata.GithubRepo, testdata.Pull, testdata.User) + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, testdata.Pull.Num, "Atlantis server is shutting down, please try again later.", "plan") } func TestRunAutoplanCommand_DrainNotOngoing(t *testing.T) { t.Log("if drain is not ongoing then remove ongoing operation must be called even if panic occurred") setup(t) - fixtures.Pull.BaseRepo = fixtures.GithubRepo + testdata.Pull.BaseRepo = testdata.GithubRepo When(projectCommandBuilder.BuildAutoplanCommands(matchers.AnyPtrToCommandContext())).ThenPanic("panic test - if you're seeing this in a test failure this isn't the failing test") - ch.RunAutoplanCommand(fixtures.GithubRepo, fixtures.GithubRepo, fixtures.Pull, fixtures.User) + ch.RunAutoplanCommand(testdata.GithubRepo, testdata.GithubRepo, testdata.Pull, testdata.User) projectCommandBuilder.VerifyWasCalledOnce().BuildAutoplanCommands(matchers.AnyPtrToCommandContext()) Equals(t, 0, drainer.GetStatus().InProgressOps) } diff --git a/server/events/event_parser_test.go b/server/events/event_parser_test.go index 23e95508a8..9b032e7a1a 100644 --- a/server/events/event_parser_test.go +++ b/server/events/event_parser_test.go @@ -27,7 +27,7 @@ import ( "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/models" - . "github.com/runatlantis/atlantis/server/events/vcs/fixtures" + . "github.com/runatlantis/atlantis/server/events/vcs/testdata" . "github.com/runatlantis/atlantis/testing" gitlab "github.com/xanzy/go-gitlab" ) diff --git a/server/events/github_app_working_dir_test.go b/server/events/github_app_working_dir_test.go index 6ea3434e3d..9598a23044 100644 --- a/server/events/github_app_working_dir_test.go +++ b/server/events/github_app_working_dir_test.go @@ -9,8 +9,8 @@ import ( eventMocks "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/events/vcs/fixtures" vcsMocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" + "github.com/runatlantis/atlantis/server/events/vcs/testdata" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) @@ -30,13 +30,13 @@ func TestClone_GithubAppNoneExisting(t *testing.T) { } defer disableSSLVerification()() - testServer, err := fixtures.GithubAppTestServer(t) + testServer, err := testdata.GithubAppTestServer(t) Ok(t, err) gwd := &events.GithubAppWorkingDir{ WorkingDir: wd, Credentials: &vcs.GithubAppCredentials{ - Key: []byte(fixtures.GithubPrivateKey), + Key: []byte(testdata.GithubPrivateKey), AppID: 1, Hostname: testServer, }, diff --git a/server/events/import_command_runner_test.go b/server/events/import_command_runner_test.go index 3c82b57502..a9a6c23fa9 100644 --- a/server/events/import_command_runner_test.go +++ b/server/events/import_command_runner_test.go @@ -7,7 +7,7 @@ import ( "github.com/runatlantis/atlantis/server/events" "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/models/fixtures" + "github.com/runatlantis/atlantis/server/events/models/testdata" "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/metrics" . "github.com/runatlantis/atlantis/testing" @@ -46,13 +46,13 @@ func TestImportCommandRunner_Run(t *testing.T) { vcsClient := setup(t) scopeNull, _, _ := metrics.NewLoggingScope(logger, "atlantis") - modelPull := models.PullRequest{BaseRepo: fixtures.GithubRepo, State: models.OpenPullState, Num: fixtures.Pull.Num} + modelPull := models.PullRequest{BaseRepo: testdata.GithubRepo, State: models.OpenPullState, Num: testdata.Pull.Num} ctx := &command.Context{ - User: fixtures.User, + User: testdata.User, Log: logging.NewNoopLogger(t), Scope: scopeNull, Pull: modelPull, - HeadRepo: fixtures.GithubRepo, + HeadRepo: testdata.GithubRepo, Trigger: command.CommentTrigger, } cmd := &events.CommentCommand{Name: command.Import} @@ -63,7 +63,7 @@ func TestImportCommandRunner_Run(t *testing.T) { importCommandRunner.Run(ctx, cmd) Assert(t, ctx.PullRequestStatus.Mergeable == true, "PullRequestStatus must be set for import_requirements") - vcsClient.VerifyWasCalledOnce().CreateComment(fixtures.GithubRepo, modelPull.Num, tt.expComment, "import") + vcsClient.VerifyWasCalledOnce().CreateComment(testdata.GithubRepo, modelPull.Num, tt.expComment, "import") }) } } diff --git a/server/events/models/fixtures/fixtures.go b/server/events/models/testdata/fixtures.go similarity index 99% rename from server/events/models/fixtures/fixtures.go rename to server/events/models/testdata/fixtures.go index 2b89f293e5..c90968a080 100644 --- a/server/events/models/fixtures/fixtures.go +++ b/server/events/models/testdata/fixtures.go @@ -11,7 +11,7 @@ // limitations under the License. // Modified hereafter by contributors to runatlantis/atlantis. -package fixtures +package testdata import ( "fmt" diff --git a/server/events/post_workflow_hooks_command_runner_test.go b/server/events/post_workflow_hooks_command_runner_test.go index 78ac8f223d..1a722666f8 100644 --- a/server/events/post_workflow_hooks_command_runner_test.go +++ b/server/events/post_workflow_hooks_command_runner_test.go @@ -14,7 +14,7 @@ import ( "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/models/fixtures" + "github.com/runatlantis/atlantis/server/events/models/testdata" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" @@ -49,13 +49,13 @@ func TestRunPostHooks_Clone(t *testing.T) { log := logging.NewNoopLogger(t) - var newPull = fixtures.Pull - newPull.BaseRepo = fixtures.GithubRepo + var newPull = testdata.Pull + newPull.BaseRepo = testdata.GithubRepo ctx := &command.Context{ Pull: newPull, - HeadRepo: fixtures.GithubRepo, - User: fixtures.User, + HeadRepo: testdata.GithubRepo, + User: testdata.User, Log: log, } @@ -69,11 +69,11 @@ func TestRunPostHooks_Clone(t *testing.T) { runtimeDesc := "" pCtx := models.WorkflowHookCommandContext{ - BaseRepo: fixtures.GithubRepo, - HeadRepo: fixtures.GithubRepo, + BaseRepo: testdata.GithubRepo, + HeadRepo: testdata.GithubRepo, Pull: newPull, Log: log, - User: fixtures.User, + User: testdata.User, Verbose: false, HookID: uuid.NewString(), } @@ -89,7 +89,7 @@ func TestRunPostHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PostWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -99,8 +99,8 @@ func TestRunPostHooks_Clone(t *testing.T) { postWh.GlobalCfg = globalCfg - When(postWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) - When(postWhWorkingDir.Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) + When(postWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) + When(postWhWorkingDir.Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) When(whPostWorkflowHookRunner.Run(pCtx, testHook.RunCommand, repoDir)).ThenReturn(result, runtimeDesc, nil) err := postWh.RunPostHooks(ctx, nil) @@ -122,7 +122,7 @@ func TestRunPostHooks_Clone(t *testing.T) { }, // one with the correct id but no hooks { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PostWorkflowHooks: []*valid.WorkflowHook{}, }, }, @@ -135,8 +135,8 @@ func TestRunPostHooks_Clone(t *testing.T) { Ok(t, err) whPostWorkflowHookRunner.VerifyWasCalled(Never()).Run(pCtx, testHook.RunCommand, repoDir) - postWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "path") - postWhWorkingDir.VerifyWasCalled(Never()).Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace) + postWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "path") + postWhWorkingDir.VerifyWasCalled(Never()).Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace) }) t.Run("error locking work dir", func(t *testing.T) { postWorkflowHooksSetup(t) @@ -144,7 +144,7 @@ func TestRunPostHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PostWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -154,12 +154,12 @@ func TestRunPostHooks_Clone(t *testing.T) { postWh.GlobalCfg = globalCfg - When(postWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(func() {}, errors.New("some error")) + When(postWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(func() {}, errors.New("some error")) err := postWh.RunPostHooks(ctx, nil) Assert(t, err != nil, "error not nil") - postWhWorkingDir.VerifyWasCalled(Never()).Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace) + postWhWorkingDir.VerifyWasCalled(Never()).Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace) whPostWorkflowHookRunner.VerifyWasCalled(Never()).Run(pCtx, testHook.RunCommand, repoDir) }) @@ -174,7 +174,7 @@ func TestRunPostHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PostWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -184,8 +184,8 @@ func TestRunPostHooks_Clone(t *testing.T) { postWh.GlobalCfg = globalCfg - When(postWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) - When(postWhWorkingDir.Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, errors.New("some error")) + When(postWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) + When(postWhWorkingDir.Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, errors.New("some error")) err := postWh.RunPostHooks(ctx, nil) @@ -206,7 +206,7 @@ func TestRunPostHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PostWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -216,8 +216,8 @@ func TestRunPostHooks_Clone(t *testing.T) { postWh.GlobalCfg = globalCfg - When(postWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) - When(postWhWorkingDir.Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) + When(postWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) + When(postWhWorkingDir.Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) When(whPostWorkflowHookRunner.Run(runtimematchers.AnyModelsWorkflowHookCommandContext(), EqString(testHook.RunCommand), EqString(repoDir))).ThenReturn(result, runtimeDesc, errors.New("some error")) err := postWh.RunPostHooks(ctx, nil) @@ -237,7 +237,7 @@ func TestRunPostHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PostWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -254,8 +254,8 @@ func TestRunPostHooks_Clone(t *testing.T) { postWh.GlobalCfg = globalCfg - When(postWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) - When(postWhWorkingDir.Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) + When(postWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) + When(postWhWorkingDir.Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) When(whPostWorkflowHookRunner.Run(runtimematchers.AnyModelsWorkflowHookCommandContext(), EqString(testHook.RunCommand), EqString(repoDir))).ThenReturn(result, runtimeDesc, nil) err := postWh.RunPostHooks(ctx, cmd) diff --git a/server/events/pre_workflow_hooks_command_runner_test.go b/server/events/pre_workflow_hooks_command_runner_test.go index 1e491f4c2a..ee1944ba1d 100644 --- a/server/events/pre_workflow_hooks_command_runner_test.go +++ b/server/events/pre_workflow_hooks_command_runner_test.go @@ -12,7 +12,7 @@ import ( "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/models/fixtures" + "github.com/runatlantis/atlantis/server/events/models/testdata" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" @@ -51,13 +51,13 @@ func TestRunPreHooks_Clone(t *testing.T) { log := logging.NewNoopLogger(t) - var newPull = fixtures.Pull - newPull.BaseRepo = fixtures.GithubRepo + var newPull = testdata.Pull + newPull.BaseRepo = testdata.GithubRepo ctx := &command.Context{ Pull: newPull, - HeadRepo: fixtures.GithubRepo, - User: fixtures.User, + HeadRepo: testdata.GithubRepo, + User: testdata.User, Log: log, } @@ -71,11 +71,11 @@ func TestRunPreHooks_Clone(t *testing.T) { runtimeDesc := "" pCtx := models.WorkflowHookCommandContext{ - BaseRepo: fixtures.GithubRepo, - HeadRepo: fixtures.GithubRepo, + BaseRepo: testdata.GithubRepo, + HeadRepo: testdata.GithubRepo, Pull: newPull, Log: log, - User: fixtures.User, + User: testdata.User, Verbose: false, } @@ -90,7 +90,7 @@ func TestRunPreHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PreWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -100,8 +100,8 @@ func TestRunPreHooks_Clone(t *testing.T) { preWh.GlobalCfg = globalCfg - When(preWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) - When(preWhWorkingDir.Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) + When(preWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) + When(preWhWorkingDir.Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) When(whPreWorkflowHookRunner.Run(runtimematchers.AnyModelsWorkflowHookCommandContext(), EqString(testHook.RunCommand), EqString(repoDir))).ThenReturn(result, runtimeDesc, nil) err := preWh.RunPreHooks(ctx, nil) @@ -124,7 +124,7 @@ func TestRunPreHooks_Clone(t *testing.T) { }, // one with the correct id but no hooks { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PreWorkflowHooks: []*valid.WorkflowHook{}, }, }, @@ -137,8 +137,8 @@ func TestRunPreHooks_Clone(t *testing.T) { Ok(t, err) whPreWorkflowHookRunner.VerifyWasCalled(Never()).Run(runtimematchers.AnyModelsWorkflowHookCommandContext(), EqString(testHook.RunCommand), EqString(repoDir)) - preWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "") - preWhWorkingDir.VerifyWasCalled(Never()).Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace) + preWhWorkingDirLocker.VerifyWasCalled(Never()).TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, "") + preWhWorkingDir.VerifyWasCalled(Never()).Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace) }) t.Run("error locking work dir", func(t *testing.T) { @@ -147,7 +147,7 @@ func TestRunPreHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PreWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -157,12 +157,12 @@ func TestRunPreHooks_Clone(t *testing.T) { preWh.GlobalCfg = globalCfg - When(preWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(func() {}, errors.New("some error")) + When(preWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(func() {}, errors.New("some error")) err := preWh.RunPreHooks(ctx, nil) Assert(t, err != nil, "error not nil") - preWhWorkingDir.VerifyWasCalled(Never()).Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace) + preWhWorkingDir.VerifyWasCalled(Never()).Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace) whPreWorkflowHookRunner.VerifyWasCalled(Never()).Run(runtimematchers.AnyModelsWorkflowHookCommandContext(), EqString(testHook.RunCommand), EqString(repoDir)) }) @@ -177,7 +177,7 @@ func TestRunPreHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PreWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -187,8 +187,8 @@ func TestRunPreHooks_Clone(t *testing.T) { preWh.GlobalCfg = globalCfg - When(preWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) - When(preWhWorkingDir.Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, errors.New("some error")) + When(preWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) + When(preWhWorkingDir.Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, errors.New("some error")) err := preWh.RunPreHooks(ctx, nil) @@ -209,7 +209,7 @@ func TestRunPreHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PreWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -219,8 +219,8 @@ func TestRunPreHooks_Clone(t *testing.T) { preWh.GlobalCfg = globalCfg - When(preWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) - When(preWhWorkingDir.Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) + When(preWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) + When(preWhWorkingDir.Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) When(whPreWorkflowHookRunner.Run(runtimematchers.AnyModelsWorkflowHookCommandContext(), EqString(testHook.RunCommand), EqString(repoDir))).ThenReturn(result, runtimeDesc, errors.New("some error")) err := preWh.RunPreHooks(ctx, nil) @@ -240,7 +240,7 @@ func TestRunPreHooks_Clone(t *testing.T) { globalCfg := valid.GlobalCfg{ Repos: []valid.Repo{ { - ID: fixtures.GithubRepo.ID(), + ID: testdata.GithubRepo.ID(), PreWorkflowHooks: []*valid.WorkflowHook{ &testHook, }, @@ -257,8 +257,8 @@ func TestRunPreHooks_Clone(t *testing.T) { preWh.GlobalCfg = globalCfg - When(preWhWorkingDirLocker.TryLock(fixtures.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) - When(preWhWorkingDir.Clone(log, fixtures.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) + When(preWhWorkingDirLocker.TryLock(testdata.GithubRepo.FullName, newPull.Num, events.DefaultWorkspace, events.DefaultRepoRelDir)).ThenReturn(unlockFn, nil) + When(preWhWorkingDir.Clone(log, testdata.GithubRepo, newPull, events.DefaultWorkspace)).ThenReturn(repoDir, false, nil) When(whPreWorkflowHookRunner.Run(runtimematchers.AnyModelsWorkflowHookCommandContext(), EqString(testHook.RunCommand), EqString(repoDir))).ThenReturn(result, runtimeDesc, nil) err := preWh.RunPreHooks(ctx, cmd) diff --git a/server/events/pull_closed_executor_test.go b/server/events/pull_closed_executor_test.go index 497ddff004..6a49686c86 100644 --- a/server/events/pull_closed_executor_test.go +++ b/server/events/pull_closed_executor_test.go @@ -30,7 +30,7 @@ import ( "github.com/runatlantis/atlantis/server/events/mocks" "github.com/runatlantis/atlantis/server/events/mocks/matchers" "github.com/runatlantis/atlantis/server/events/models" - "github.com/runatlantis/atlantis/server/events/models/fixtures" + "github.com/runatlantis/atlantis/server/events/models/testdata" vcsmocks "github.com/runatlantis/atlantis/server/events/vcs/mocks" loggermocks "github.com/runatlantis/atlantis/server/logging/mocks" . "github.com/runatlantis/atlantis/testing" @@ -49,8 +49,8 @@ func TestCleanUpPullWorkspaceErr(t *testing.T) { Backend: db, } err = errors.New("err") - When(w.Delete(fixtures.GithubRepo, fixtures.Pull)).ThenReturn(err) - actualErr := pce.CleanUpPull(fixtures.GithubRepo, fixtures.Pull) + When(w.Delete(testdata.GithubRepo, testdata.Pull)).ThenReturn(err) + actualErr := pce.CleanUpPull(testdata.GithubRepo, testdata.Pull) Equals(t, "cleaning workspace: err", actualErr.Error()) } @@ -69,8 +69,8 @@ func TestCleanUpPullUnlockErr(t *testing.T) { PullClosedTemplate: &events.PullClosedEventTemplate{}, } err = errors.New("err") - When(l.UnlockByPull(fixtures.GithubRepo.FullName, fixtures.Pull.Num)).ThenReturn(nil, err) - actualErr := pce.CleanUpPull(fixtures.GithubRepo, fixtures.Pull) + When(l.UnlockByPull(testdata.GithubRepo.FullName, testdata.Pull.Num)).ThenReturn(nil, err) + actualErr := pce.CleanUpPull(testdata.GithubRepo, testdata.Pull) Equals(t, "cleaning up locks: err", actualErr.Error()) } @@ -89,8 +89,8 @@ func TestCleanUpPullNoLocks(t *testing.T) { WorkingDir: w, Backend: db, } - When(l.UnlockByPull(fixtures.GithubRepo.FullName, fixtures.Pull.Num)).ThenReturn(nil, nil) - err = pce.CleanUpPull(fixtures.GithubRepo, fixtures.Pull) + When(l.UnlockByPull(testdata.GithubRepo.FullName, testdata.Pull.Num)).ThenReturn(nil, nil) + err = pce.CleanUpPull(testdata.GithubRepo, testdata.Pull) Ok(t, err) cp.VerifyWasCalled(Never()).CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()) } @@ -175,8 +175,8 @@ func TestCleanUpPullComments(t *testing.T) { Backend: db, } t.Log("testing: " + c.Description) - When(l.UnlockByPull(fixtures.GithubRepo.FullName, fixtures.Pull.Num)).ThenReturn(c.Locks, nil) - err = pce.CleanUpPull(fixtures.GithubRepo, fixtures.Pull) + When(l.UnlockByPull(testdata.GithubRepo.FullName, testdata.Pull.Num)).ThenReturn(c.Locks, nil) + err = pce.CleanUpPull(testdata.GithubRepo, testdata.Pull) Ok(t, err) _, _, comment, _ := cp.VerifyWasCalledOnce().CreateComment(matchers.AnyModelsRepo(), AnyInt(), AnyString(), AnyString()).GetCapturedArguments() @@ -195,9 +195,9 @@ func TestCleanUpLogStreaming(t *testing.T) { prjCmdOutput := make(chan *jobs.ProjectCmdOutputLine) prjCmdOutHandler := jobs.NewAsyncProjectCommandOutputHandler(prjCmdOutput, logger) ctx := command.ProjectContext{ - BaseRepo: fixtures.GithubRepo, - Pull: fixtures.Pull, - ProjectName: *fixtures.Project.Name, + BaseRepo: testdata.GithubRepo, + Pull: testdata.Pull, + ProjectName: *testdata.Project.Name, Workspace: "default", } @@ -232,14 +232,14 @@ func TestCleanUpLogStreaming(t *testing.T) { db, _ := db.NewWithDB(boltDB, lockBucket, configBucket) result := []command.ProjectResult{ { - RepoRelDir: fixtures.GithubRepo.FullName, + RepoRelDir: testdata.GithubRepo.FullName, Workspace: "default", - ProjectName: *fixtures.Project.Name, + ProjectName: *testdata.Project.Name, }, } // Create a new record for pull - _, err = db.UpdatePullWithResults(fixtures.Pull, result) + _, err = db.UpdatePullWithResults(testdata.Pull, result) Ok(t, err) workingDir := mocks.NewMockWorkingDir() @@ -259,14 +259,14 @@ func TestCleanUpLogStreaming(t *testing.T) { locks := []models.ProjectLock{ { - Project: models.NewProject(fixtures.GithubRepo.FullName, ""), + Project: models.NewProject(testdata.GithubRepo.FullName, ""), Workspace: "default", }, } - When(locker.UnlockByPull(fixtures.GithubRepo.FullName, fixtures.Pull.Num)).ThenReturn(locks, nil) + When(locker.UnlockByPull(testdata.GithubRepo.FullName, testdata.Pull.Num)).ThenReturn(locks, nil) // Clean up. - err = pullClosedExecutor.CleanUpPull(fixtures.GithubRepo, fixtures.Pull) + err = pullClosedExecutor.CleanUpPull(testdata.GithubRepo, testdata.Pull) Ok(t, err) close(prjCmdOutput) diff --git a/server/events/terraform/ansi/strip_test.go b/server/events/terraform/ansi/strip_test.go new file mode 100644 index 0000000000..51c7233467 --- /dev/null +++ b/server/events/terraform/ansi/strip_test.go @@ -0,0 +1,30 @@ +package ansi + +import "testing" + +func TestStrip(t *testing.T) { + tests := []struct { + name string + str string + want string + }{ + { + name: "strip ansi", + str: ` ++ create +Plan: 3 to add, 0 to change, 0 to destroy. +`, + want: ` ++ create +Plan: 3 to add, 0 to change, 0 to destroy. +`, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := Strip(tt.str); got != tt.want { + t.Errorf("Strip() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/server/events/vcs/azuredevops_client_test.go b/server/events/vcs/azuredevops_client_test.go index f824d1cfd9..da29b0dadf 100644 --- a/server/events/vcs/azuredevops_client_test.go +++ b/server/events/vcs/azuredevops_client_test.go @@ -14,7 +14,7 @@ import ( "github.com/mcdafydd/go-azuredevops/azuredevops" "github.com/runatlantis/atlantis/server/events/models" "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/events/vcs/fixtures" + "github.com/runatlantis/atlantis/server/events/vcs/testdata" . "github.com/runatlantis/atlantis/testing" ) @@ -262,7 +262,7 @@ func TestAzureDevopsClient_GetModifiedFiles(t *testing.T) { switch r.RequestURI { // The first request should hit this URL. case "/owner/project/_apis/git/repositories/repo/pullrequests/1?api-version=5.1-preview.1&includeWorkItemRefs=true": - w.Write([]byte(fixtures.ADPullJSON)) // nolint: errcheck + w.Write([]byte(testdata.ADPullJSON)) // nolint: errcheck // The second should hit this URL. case "/owner/project/_apis/git/repositories/repo/diffs/commits?api-version=5.1&baseVersion=new_feature&targetVersion=npaulk/my_work": // We write a header that means there's an additional page. @@ -362,10 +362,10 @@ func TestAzureDevopsClient_PullIsMergeable(t *testing.T) { }, } - jsonPullRequestBytes, err := os.ReadFile("fixtures/azuredevops-pr.json") + jsonPullRequestBytes, err := os.ReadFile("testdata/azuredevops-pr.json") Ok(t, err) - jsonPolicyEvaluationBytes, err := os.ReadFile("fixtures/azuredevops-policyevaluations.json") + jsonPolicyEvaluationBytes, err := os.ReadFile("testdata/azuredevops-policyevaluations.json") Ok(t, err) pullRequestBody := string(jsonPullRequestBytes) @@ -466,7 +466,7 @@ func TestAzureDevopsClient_PullIsApproved(t *testing.T) { }, } - jsBytes, err := os.ReadFile("fixtures/azuredevops-pr.json") + jsBytes, err := os.ReadFile("testdata/azuredevops-pr.json") Ok(t, err) json := string(jsBytes) @@ -517,7 +517,7 @@ func TestAzureDevopsClient_PullIsApproved(t *testing.T) { func TestAzureDevopsClient_GetPullRequest(t *testing.T) { // Use a real Azure DevOps json response and edit the mergeable_state field. - jsBytes, err := os.ReadFile("fixtures/azuredevops-pr.json") + jsBytes, err := os.ReadFile("testdata/azuredevops-pr.json") Ok(t, err) response := string(jsBytes) diff --git a/server/events/vcs/github_client_test.go b/server/events/vcs/github_client_test.go index 331abeac46..c1c30f03d4 100644 --- a/server/events/vcs/github_client_test.go +++ b/server/events/vcs/github_client_test.go @@ -514,12 +514,12 @@ func TestGithubClient_PullIsMergeable(t *testing.T) { } // Use a real GitHub json response and edit the mergeable_state field. - jsBytes, err := os.ReadFile("fixtures/github-pull-request.json") + jsBytes, err := os.ReadFile("testdata/github-pull-request.json") Ok(t, err) prJSON := string(jsBytes) // Status Check Response - jsBytes, err = os.ReadFile("fixtures/github-commit-status-full.json") + jsBytes, err = os.ReadFile("testdata/github-commit-status-full.json") Ok(t, err) commitJSON := string(jsBytes) @@ -651,22 +651,22 @@ func TestGithubClient_PullIsMergeableWithAllowMergeableBypassApply(t *testing.T) } // Use a real GitHub json response and edit the mergeable_state field. - jsBytes, err := os.ReadFile("fixtures/github-pull-request.json") + jsBytes, err := os.ReadFile("testdata/github-pull-request.json") Ok(t, err) prJSON := string(jsBytes) // Status Check Response - jsBytes, err = os.ReadFile("fixtures/github-commit-status-full.json") + jsBytes, err = os.ReadFile("testdata/github-commit-status-full.json") Ok(t, err) commitJSON := string(jsBytes) // Branch protection Response - jsBytes, err = os.ReadFile("fixtures/github-branch-protection-required-checks.json") + jsBytes, err = os.ReadFile("testdata/github-branch-protection-required-checks.json") Ok(t, err) branchProtectionJSON := string(jsBytes) // List check suites Response - jsBytes, err = os.ReadFile("fixtures/github-commit-check-suites.json") + jsBytes, err = os.ReadFile("testdata/github-commit-check-suites.json") Ok(t, err) checkSuites := string(jsBytes) @@ -762,7 +762,7 @@ func TestGithubClient_MergePullHandlesError(t *testing.T) { }, } - jsBytes, err := os.ReadFile("fixtures/github-repo.json") + jsBytes, err := os.ReadFile("testdata/github-repo.json") Ok(t, err) for _, c := range cases { @@ -872,7 +872,7 @@ func TestGithubClient_MergePullCorrectMethod(t *testing.T) { t.Run(name, func(t *testing.T) { // Modify response. - jsBytes, err := os.ReadFile("fixtures/github-repo.json") + jsBytes, err := os.ReadFile("testdata/github-repo.json") Ok(t, err) resp := string(jsBytes) resp = strings.Replace(resp, diff --git a/server/events/vcs/github_credentials_test.go b/server/events/vcs/github_credentials_test.go index 1150194d06..f6975056c9 100644 --- a/server/events/vcs/github_credentials_test.go +++ b/server/events/vcs/github_credentials_test.go @@ -4,14 +4,14 @@ import ( "testing" "github.com/runatlantis/atlantis/server/events/vcs" - "github.com/runatlantis/atlantis/server/events/vcs/fixtures" + "github.com/runatlantis/atlantis/server/events/vcs/testdata" "github.com/runatlantis/atlantis/server/logging" . "github.com/runatlantis/atlantis/testing" ) func TestGithubClient_GetUser_AppSlug(t *testing.T) { defer disableSSLVerification()() - testServer, err := fixtures.GithubAppTestServer(t) + testServer, err := testdata.GithubAppTestServer(t) Ok(t, err) anonCreds := &vcs.GithubAnonymousCredentials{} @@ -22,7 +22,7 @@ func TestGithubClient_GetUser_AppSlug(t *testing.T) { appCreds := &vcs.GithubAppCredentials{ AppID: tempSecrets.ID, - Key: []byte(fixtures.GithubPrivateKey), + Key: []byte(testdata.GithubPrivateKey), Hostname: testServer, AppSlug: "some-app", } @@ -35,7 +35,7 @@ func TestGithubClient_GetUser_AppSlug(t *testing.T) { func TestGithubClient_AppAuthentication(t *testing.T) { defer disableSSLVerification()() - testServer, err := fixtures.GithubAppTestServer(t) + testServer, err := testdata.GithubAppTestServer(t) Ok(t, err) anonCreds := &vcs.GithubAnonymousCredentials{} @@ -46,7 +46,7 @@ func TestGithubClient_AppAuthentication(t *testing.T) { appCreds := &vcs.GithubAppCredentials{ AppID: tempSecrets.ID, - Key: []byte(fixtures.GithubPrivateKey), + Key: []byte(testdata.GithubPrivateKey), Hostname: testServer, } _, err = vcs.NewGithubClient(testServer, appCreds, vcs.GithubConfig{}, logging.NewNoopLogger(t)) diff --git a/server/events/vcs/fixtures/azuredevops-policyevaluations.json b/server/events/vcs/testdata/azuredevops-policyevaluations.json similarity index 100% rename from server/events/vcs/fixtures/azuredevops-policyevaluations.json rename to server/events/vcs/testdata/azuredevops-policyevaluations.json diff --git a/server/events/vcs/fixtures/azuredevops-pr.json b/server/events/vcs/testdata/azuredevops-pr.json similarity index 100% rename from server/events/vcs/fixtures/azuredevops-pr.json rename to server/events/vcs/testdata/azuredevops-pr.json diff --git a/server/events/vcs/fixtures/fixtures.go b/server/events/vcs/testdata/fixtures.go similarity index 99% rename from server/events/vcs/fixtures/fixtures.go rename to server/events/vcs/testdata/fixtures.go index f8bd496cde..21195babe6 100644 --- a/server/events/vcs/fixtures/fixtures.go +++ b/server/events/vcs/testdata/fixtures.go @@ -11,7 +11,7 @@ // limitations under the License. // Modified hereafter by contributors to runatlantis/atlantis. -package fixtures +package testdata import ( "fmt" diff --git a/server/events/vcs/fixtures/github-branch-protection-required-checks.json b/server/events/vcs/testdata/github-branch-protection-required-checks.json similarity index 100% rename from server/events/vcs/fixtures/github-branch-protection-required-checks.json rename to server/events/vcs/testdata/github-branch-protection-required-checks.json diff --git a/server/events/vcs/fixtures/github-commit-check-suites.json b/server/events/vcs/testdata/github-commit-check-suites.json similarity index 100% rename from server/events/vcs/fixtures/github-commit-check-suites.json rename to server/events/vcs/testdata/github-commit-check-suites.json diff --git a/server/events/vcs/fixtures/github-commit-status-full.json b/server/events/vcs/testdata/github-commit-status-full.json similarity index 100% rename from server/events/vcs/fixtures/github-commit-status-full.json rename to server/events/vcs/testdata/github-commit-status-full.json diff --git a/server/events/vcs/fixtures/github-pull-request.json b/server/events/vcs/testdata/github-pull-request.json similarity index 100% rename from server/events/vcs/fixtures/github-pull-request.json rename to server/events/vcs/testdata/github-pull-request.json diff --git a/server/events/vcs/fixtures/github-repo.json b/server/events/vcs/testdata/github-repo.json similarity index 100% rename from server/events/vcs/fixtures/github-repo.json rename to server/events/vcs/testdata/github-repo.json diff --git a/server/metrics/counter_test.go b/server/metrics/counter_test.go new file mode 100644 index 0000000000..b61d43e716 --- /dev/null +++ b/server/metrics/counter_test.go @@ -0,0 +1,21 @@ +package metrics + +import ( + "testing" + + "github.com/uber-go/tally" +) + +func TestInitCounter(t *testing.T) { + scope := tally.NewTestScope("test", nil) + + InitCounter(scope, "counter") + + counter, ok := scope.Snapshot().Counters()["test.counter+"] + if !ok { + t.Errorf("Counter not found") + } + if counter.Value() != 0 { + t.Errorf("Counter is not initialized") + } +} diff --git a/server/metrics/scope.go b/server/metrics/scope.go index 02595f8940..55f86b9368 100644 --- a/server/metrics/scope.go +++ b/server/metrics/scope.go @@ -45,7 +45,7 @@ func newReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.BaseSta // return statsd metrics if configured if cfg.Statsd != nil { - return newStatsReporter(cfg, logger) + return newStatsReporter(cfg) } // return prometheus metrics if configured @@ -58,7 +58,7 @@ func newReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.BaseSta } -func newStatsReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.StatsReporter, error) { +func newStatsReporter(cfg valid.Metrics) (tally.StatsReporter, error) { statsdCfg := cfg.Statsd diff --git a/server/recovery/recovery_test.go b/server/recovery/recovery_test.go index fbab2e89d2..2c80162458 100644 --- a/server/recovery/recovery_test.go +++ b/server/recovery/recovery_test.go @@ -13,4 +13,87 @@ package recovery_test -// purposefully empty to trigger coverage report +import ( + "fmt" + "strings" + "testing" + + "github.com/runatlantis/atlantis/server/recovery" +) + +func TestStack(t *testing.T) { + tests := []struct { + skip int + expContains []string + expNotContains []string + }{ + { + skip: 0, + expContains: []string{ + "runtime.Caller(i)", + "TestStack.func1.1: return string(recovery.Stack(tt.skip))", + "recoveryTestFunc2: return f()", + "recoveryTestFunc1: return recoveryTestFunc2(f)", + }, + expNotContains: []string{}, + }, + { + skip: 1, + expContains: []string{ + "TestStack.func1.1: return string(recovery.Stack(tt.skip))", + "recoveryTestFunc2: return f()", + "recoveryTestFunc1: return recoveryTestFunc2(f)", + }, + expNotContains: []string{ + "runtime.Caller(i)", + }, + }, + { + skip: 2, + expContains: []string{ + "recoveryTestFunc2: return f()", + "recoveryTestFunc1: return recoveryTestFunc2(f)", + }, + expNotContains: []string{ + "runtime.Caller(i)", + "TestStack.func1.1: return string(recovery.Stack(tt.skip))", + }, + }, + { + skip: 3, + expContains: []string{ + "recoveryTestFunc1: return recoveryTestFunc2(f)", + }, + expNotContains: []string{ + "runtime.Caller(i)", + "TestStack.func1.1: return string(recovery.Stack(tt.skip))", + "recoveryTestFunc2: return f()", + }, + }, + } + for _, tt := range tests { + t.Run(fmt.Sprintf("skip %d", tt.skip), func(t *testing.T) { + got := recoveryTestFunc1(func() string { + return string(recovery.Stack(tt.skip)) + }) + for _, contain := range tt.expContains { + if !strings.Contains(got, contain) { + t.Fatalf("expected stack to contain %q but got:\n%s", contain, got) + } + } + for _, notContain := range tt.expNotContains { + if strings.Contains(got, notContain) { + t.Fatalf("expected stack to not contain %q but got:\n%s", notContain, got) + } + } + }) + } +} + +func recoveryTestFunc1(f func() string) string { + return recoveryTestFunc2(f) +} + +func recoveryTestFunc2(f func() string) string { + return f() +} diff --git a/server/scheduled/runtime_stats_test.go b/server/scheduled/runtime_stats_test.go new file mode 100644 index 0000000000..2ee0c38534 --- /dev/null +++ b/server/scheduled/runtime_stats_test.go @@ -0,0 +1,18 @@ +package scheduled + +import ( + "testing" + + "github.com/uber-go/tally" +) + +func TestRuntimeStatCollector_Run(t *testing.T) { + scope := tally.NewTestScope("test", nil) + r := NewRuntimeStats(scope) + r.Run() + + expGaugeCount := 25 + if len(scope.Snapshot().Gauges()) != expGaugeCount { + t.Errorf("Expected %d gauges but got %d", expGaugeCount, len(scope.Snapshot().Gauges())) + } +}