Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "data race" in testlogger #9159

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integrations/api_admin_org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestAPIAdminOrgCreateBadVisibility(t *testing.T) {
}

func TestAPIAdminOrgCreateNotAdmin(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
nonAdminUsername := "user2"
session := loginUser(t, nonAdminUsername)
token := getTokenForLoggedInUser(t, session)
Expand Down
16 changes: 8 additions & 8 deletions integrations/api_admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func TestAPIAdminCreateAndDeleteSSHKey(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
// user1 is an admin user
session := loginUser(t, "user1")
keyOwner := models.AssertExistsAndLoadBean(t, &models.User{Name: "user2"}).(*models.User)
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestAPIAdminCreateAndDeleteSSHKey(t *testing.T) {
}

func TestAPIAdminDeleteMissingSSHKey(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
// user1 is an admin user
session := loginUser(t, "user1")

Expand All @@ -56,7 +56,7 @@ func TestAPIAdminDeleteMissingSSHKey(t *testing.T) {
}

func TestAPIAdminDeleteUnauthorizedKey(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
adminUsername := "user1"
normalUsername := "user2"
session := loginUser(t, adminUsername)
Expand All @@ -79,7 +79,7 @@ func TestAPIAdminDeleteUnauthorizedKey(t *testing.T) {
}

func TestAPISudoUser(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
adminUsername := "user1"
normalUsername := "user2"
session := loginUser(t, adminUsername)
Expand All @@ -95,7 +95,7 @@ func TestAPISudoUser(t *testing.T) {
}

func TestAPISudoUserForbidden(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
adminUsername := "user1"
normalUsername := "user2"

Expand All @@ -108,7 +108,7 @@ func TestAPISudoUserForbidden(t *testing.T) {
}

func TestAPIListUsers(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
adminUsername := "user1"
session := loginUser(t, adminUsername)
token := getTokenForLoggedInUser(t, session)
Expand All @@ -131,13 +131,13 @@ func TestAPIListUsers(t *testing.T) {
}

func TestAPIListUsersNotLoggedIn(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequest(t, "GET", "/api/v1/admin/users")
MakeRequest(t, req, http.StatusUnauthorized)
}

func TestAPIListUsersNonAdmin(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
nonAdminUsername := "user2"
session := loginUser(t, nonAdminUsername)
token := getTokenForLoggedInUser(t, session)
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func testAPIGetBranch(t *testing.T, branchName string, exists bool) {
prepareTestEnv(t)
defer prepareTestEnv(t)()

session := loginUser(t, "user2")
token := getTokenForLoggedInUser(t, session)
Expand Down
10 changes: 5 additions & 5 deletions integrations/api_comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func TestAPIListRepoComments(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()

comment := models.AssertExistsAndLoadBean(t, &models.Comment{},
models.Cond("type = ?", models.CommentTypeComment)).(*models.Comment)
Expand All @@ -40,7 +40,7 @@ func TestAPIListRepoComments(t *testing.T) {
}

func TestAPIListIssueComments(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()

comment := models.AssertExistsAndLoadBean(t, &models.Comment{},
models.Cond("type = ?", models.CommentTypeComment)).(*models.Comment)
Expand All @@ -61,7 +61,7 @@ func TestAPIListIssueComments(t *testing.T) {
}

func TestAPICreateComment(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
const commentBody = "Comment body"

issue := models.AssertExistsAndLoadBean(t, &models.Issue{}).(*models.Issue)
Expand All @@ -84,7 +84,7 @@ func TestAPICreateComment(t *testing.T) {
}

func TestAPIEditComment(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
const newCommentBody = "This is the new comment body"

comment := models.AssertExistsAndLoadBean(t, &models.Comment{},
Expand All @@ -110,7 +110,7 @@ func TestAPIEditComment(t *testing.T) {
}

func TestAPIDeleteComment(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()

comment := models.AssertExistsAndLoadBean(t, &models.Comment{},
models.Cond("type = ?", models.CommentTypeComment)).(*models.Comment)
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestCreateForkNoLogin(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequestWithJSON(t, "POST", "/api/v1/repos/user2/repo1/forks", &api.CreateForkOption{})
MakeRequest(t, req, http.StatusUnauthorized)
}
2 changes: 1 addition & 1 deletion integrations/api_gpg_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
type makeRequestFunc func(testing.TB, *http.Request, int) *httptest.ResponseRecorder

func TestGPGKeys(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
session := loginUser(t, "user2")
token := getTokenForLoggedInUser(t, session)

Expand Down
4 changes: 2 additions & 2 deletions integrations/api_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func TestAPIListIssues(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()

repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
Expand All @@ -35,7 +35,7 @@ func TestAPIListIssues(t *testing.T) {
}

func TestAPICreateIssue(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
const body, title = "apiTestBody", "apiTestTitle"

repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
Expand Down
14 changes: 7 additions & 7 deletions integrations/api_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import (
)

func TestViewDeployKeysNoLogin(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo1/keys")
MakeRequest(t, req, http.StatusUnauthorized)
}

func TestCreateDeployKeyNoLogin(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequestWithJSON(t, "POST", "/api/v1/repos/user2/repo1/keys", api.CreateKeyOption{
Title: "title",
Key: "key",
Expand All @@ -32,19 +32,19 @@ func TestCreateDeployKeyNoLogin(t *testing.T) {
}

func TestGetDeployKeyNoLogin(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo1/keys/1")
MakeRequest(t, req, http.StatusUnauthorized)
}

func TestDeleteDeployKeyNoLogin(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequest(t, "DELETE", "/api/v1/repos/user2/repo1/keys/1")
MakeRequest(t, req, http.StatusUnauthorized)
}

func TestCreateReadOnlyDeployKey(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo := models.AssertExistsAndLoadBean(t, &models.Repository{Name: "repo1"}).(*models.Repository)
repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)

Expand All @@ -70,7 +70,7 @@ func TestCreateReadOnlyDeployKey(t *testing.T) {
}

func TestCreateReadWriteDeployKey(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo := models.AssertExistsAndLoadBean(t, &models.Repository{Name: "repo1"}).(*models.Repository)
repoOwner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)

Expand All @@ -95,7 +95,7 @@ func TestCreateReadWriteDeployKey(t *testing.T) {
}

func TestCreateUserKey(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{Name: "user1"}).(*models.User)

session := loginUser(t, "user1")
Expand Down
8 changes: 4 additions & 4 deletions integrations/api_pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

func TestAPIViewPulls(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)

Expand All @@ -36,7 +36,7 @@ func TestAPIViewPulls(t *testing.T) {

// TestAPIMergePullWIP ensures that we can't merge a WIP pull request
func TestAPIMergePullWIP(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
pr := models.AssertExistsAndLoadBean(t, &models.PullRequest{Status: models.PullRequestStatusMergeable}, models.Cond("has_merged = ?", false)).(*models.PullRequest)
Expand All @@ -59,7 +59,7 @@ func TestAPIMergePullWIP(t *testing.T) {
}

func TestAPICreatePullSuccess1(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository)
// repo10 have code, pulls units.
repo11 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 11}).(*models.Repository)
Expand All @@ -79,7 +79,7 @@ func TestAPICreatePullSuccess1(t *testing.T) {
}

func TestAPICreatePullSuccess2(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository)
owner10 := models.AssertExistsAndLoadBean(t, &models.User{ID: repo10.OwnerID}).(*models.User)

Expand Down
6 changes: 3 additions & 3 deletions integrations/api_releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func createNewReleaseUsingAPI(t *testing.T, session *TestSession, token string,
}

func TestAPICreateAndUpdateRelease(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()

repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestAPICreateAndUpdateRelease(t *testing.T) {
}

func TestAPICreateReleaseToDefaultBranch(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()

repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
Expand All @@ -104,7 +104,7 @@ func TestAPICreateReleaseToDefaultBranch(t *testing.T) {
}

func TestAPICreateReleaseToDefaultBranchOnExistingTag(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()

repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
Expand Down
2 changes: 1 addition & 1 deletion integrations/api_repo_git_blobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

func TestAPIReposGitBlobs(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) // owner of the repo1 & repo16
user3 := models.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User) // owner of the repo3
user4 := models.AssertExistsAndLoadBean(t, &models.User{ID: 4}).(*models.User) // owner of neither repos
Expand Down
8 changes: 4 additions & 4 deletions integrations/api_repo_git_commits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

func TestAPIReposGitCommits(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
// Login as User2.
session := loginUser(t, user.Name)
Expand All @@ -35,7 +35,7 @@ func TestAPIReposGitCommits(t *testing.T) {
}

func TestAPIReposGitCommitList(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
// Login as User2.
session := loginUser(t, user.Name)
Expand All @@ -55,7 +55,7 @@ func TestAPIReposGitCommitList(t *testing.T) {
}

func TestAPIReposGitCommitListPage2Empty(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
// Login as User2.
session := loginUser(t, user.Name)
Expand All @@ -72,7 +72,7 @@ func TestAPIReposGitCommitListPage2Empty(t *testing.T) {
}

func TestAPIReposGitCommitListDifferentBranch(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
// Login as User2.
session := loginUser(t, user.Name)
Expand Down
Loading