mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 20:18:24 +00:00
chore(test): add no test dir tests, rename testdata dir (#2986)
* add web_templates render tests * add ansic strip tests * move fixtures into testdata dir which is golang specific test dir name * add server/metrics tests * add recovery test * add runtime stats test
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user