Browse Source

Fix "data race" in testlogger (#9159)

* Fix data race in testlogger

* Update git_helper_for_declarative_test.go
lunny/display_deleted_branch2
zeripath 3 years ago
committed by Lauris BH
parent
commit
055f6d2296
  1. 2
      integrations/api_admin_org_test.go
  2. 16
      integrations/api_admin_test.go
  3. 2
      integrations/api_branch_test.go
  4. 10
      integrations/api_comment_test.go
  5. 2
      integrations/api_fork_test.go
  6. 2
      integrations/api_gpg_keys_test.go
  7. 4
      integrations/api_issue_test.go
  8. 14
      integrations/api_keys_test.go
  9. 8
      integrations/api_pull_test.go
  10. 6
      integrations/api_releases_test.go
  11. 2
      integrations/api_repo_git_blobs_test.go
  12. 8
      integrations/api_repo_git_commits_test.go
  13. 18
      integrations/api_repo_git_hook_test.go
  14. 2
      integrations/api_repo_git_ref_test.go
  15. 2
      integrations/api_repo_git_tags_test.go
  16. 2
      integrations/api_repo_git_trees_test.go
  17. 6
      integrations/api_repo_lfs_locks_test.go
  18. 2
      integrations/api_repo_raw_test.go
  19. 2
      integrations/api_repo_tags_test.go
  20. 14
      integrations/api_repo_test.go
  21. 2
      integrations/api_repo_topic_test.go
  22. 4
      integrations/api_team_test.go
  23. 2
      integrations/api_team_user_test.go
  24. 4
      integrations/api_token_test.go
  25. 2
      integrations/api_user_heatmap_test.go
  26. 4
      integrations/api_user_orgs_test.go
  27. 4
      integrations/api_user_search_test.go
  28. 8
      integrations/auth_ldap_test.go
  29. 6
      integrations/branches_test.go
  30. 2
      integrations/change_default_branch_test.go
  31. 2
      integrations/cors_test.go
  32. 6
      integrations/create_no_session_test.go
  33. 6
      integrations/delete_user_test.go
  34. 4
      integrations/download_test.go
  35. 2
      integrations/empty_repo_test.go
  36. 2
      integrations/explore_repos_test.go
  37. 22
      integrations/git_test.go
  38. 24
      integrations/gpg_git_test.go
  39. 5
      integrations/integration_test.go
  40. 14
      integrations/issue_test.go
  41. 2
      integrations/lfs_getobject_test.go
  42. 6
      integrations/links_test.go
  43. 9
      integrations/migration-test/migration_test.go
  44. 2
      integrations/nonascii_branches_test.go
  45. 20
      integrations/oauth_test.go
  46. 6
      integrations/org_test.go
  47. 2
      integrations/pull_compare_test.go
  48. 12
      integrations/pull_merge_test.go
  49. 2
      integrations/pull_review_test.go
  50. 12
      integrations/release_test.go
  51. 4
      integrations/repo_branch_test.go
  52. 2
      integrations/repo_commits_search_test.go
  53. 4
      integrations/repo_commits_test.go
  54. 4
      integrations/repo_fork_test.go
  55. 4
      integrations/repo_generate_test.go
  56. 2
      integrations/repo_migrate_test.go
  57. 2
      integrations/repo_search_test.go
  58. 14
      integrations/repo_test.go
  59. 6
      integrations/setting_test.go
  60. 2
      integrations/signin_test.go
  61. 2
      integrations/signout_test.go
  62. 2
      integrations/signup_test.go
  63. 23
      integrations/testlogger.go
  64. 6
      integrations/timetracking_test.go
  65. 10
      integrations/user_test.go
  66. 2
      integrations/version_test.go
  67. 2
      integrations/xss_test.go

2
integrations/api_admin_org_test.go

@ -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)

16
integrations/api_admin_test.go

@ -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)
@ -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")
@ -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)
@ -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)
@ -95,7 +95,7 @@ func TestAPISudoUser(t *testing.T) {
}
func TestAPISudoUserForbidden(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
adminUsername := "user1"
normalUsername := "user2"
@ -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)
@ -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)

2
integrations/api_branch_test.go

@ -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)

10
integrations/api_comment_test.go

@ -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)
@ -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)
@ -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)
@ -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{},
@ -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)

2
integrations/api_fork_test.go

@ -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
integrations/api_gpg_keys_test.go

@ -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)

4
integrations/api_issue_test.go

@ -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)
@ -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)

14
integrations/api_keys_test.go

@ -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",
@ -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)
@ -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)
@ -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")

8
integrations/api_pull_test.go

@ -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)
@ -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)
@ -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)
@ -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)

6
integrations/api_releases_test.go

@ -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)
@ -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)
@ -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)

2
integrations/api_repo_git_blobs_test.go

@ -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

8
integrations/api_repo_git_commits_test.go

@ -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)
@ -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)
@ -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)
@ -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)

18
integrations/api_repo_git_hook_test.go

@ -21,7 +21,7 @@ echo Hello, World!
`
func TestAPIListGitHooks(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 37}).(*models.Repository)
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
@ -47,7 +47,7 @@ func TestAPIListGitHooks(t *testing.T) {
}
func TestAPIListGitHooksNoHooks(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)
@ -68,7 +68,7 @@ func TestAPIListGitHooksNoHooks(t *testing.T) {
}
func TestAPIListGitHooksNoAccess(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)
@ -81,7 +81,7 @@ func TestAPIListGitHooksNoAccess(t *testing.T) {
}
func TestAPIGetGitHook(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 37}).(*models.Repository)
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
@ -99,7 +99,7 @@ func TestAPIGetGitHook(t *testing.T) {
}
func TestAPIGetGitHookNoAccess(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)
@ -112,7 +112,7 @@ func TestAPIGetGitHookNoAccess(t *testing.T) {
}
func TestAPIEditGitHook(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)
@ -142,7 +142,7 @@ func TestAPIEditGitHook(t *testing.T) {
}
func TestAPIEditGitHookNoAccess(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)
@ -158,7 +158,7 @@ func TestAPIEditGitHookNoAccess(t *testing.T) {
}
func TestAPIDeleteGitHook(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 37}).(*models.Repository)
owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
@ -181,7 +181,7 @@ func TestAPIDeleteGitHook(t *testing.T) {
}
func TestAPIDeleteGitHookNoAccess(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)

2
integrations/api_repo_git_ref_test.go

@ -12,7 +12,7 @@ import (
)
func TestAPIReposGitRefs(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)

2
integrations/api_repo_git_tags_test.go

@ -17,7 +17,7 @@ import (
)
func TestAPIGitTags(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
// Login as User2.

2
integrations/api_repo_git_trees_test.go

@ -12,7 +12,7 @@ import (
)
func TestAPIReposGitTrees(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

6
integrations/api_repo_lfs_locks_test.go

@ -18,7 +18,7 @@ import (
)
func TestAPILFSLocksNotStarted(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
setting.LFS.StartServer = false
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
@ -34,7 +34,7 @@ func TestAPILFSLocksNotStarted(t *testing.T) {
}
func TestAPILFSLocksNotLogin(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
setting.LFS.StartServer = true
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
@ -48,7 +48,7 @@ func TestAPILFSLocksNotLogin(t *testing.T) {
}
func TestAPILFSLocksLogged(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
setting.LFS.StartServer = true
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) //in org 3
user4 := models.AssertExistsAndLoadBean(t, &models.User{ID: 4}).(*models.User) //in org 3

2
integrations/api_repo_raw_test.go

@ -12,7 +12,7 @@ import (
)
func TestAPIReposRaw(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)

2
integrations/api_repo_tags_test.go

@ -16,7 +16,7 @@ import (
)
func TestAPIReposGetTags(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)

14
integrations/api_repo_test.go

@ -19,7 +19,7 @@ import (
)
func TestAPIUserReposNotLogin(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
req := NewRequestf(t, "GET", "/api/v1/users/%s/repos", user.Name)
@ -37,7 +37,7 @@ func TestAPIUserReposNotLogin(t *testing.T) {
}
func TestAPISearchRepo(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
const keyword = "test"
req := NewRequestf(t, "GET", "/api/v1/repos/search?q=%s", keyword)
@ -207,7 +207,7 @@ func getRepo(t *testing.T, repoID int64) *models.Repository {
}
func TestAPIViewRepo(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo1")
resp := MakeRequest(t, req, http.StatusOK)
@ -219,7 +219,7 @@ func TestAPIViewRepo(t *testing.T) {
}
func TestAPIOrgRepos(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
user3 := models.AssertExistsAndLoadBean(t, &models.User{ID: 5}).(*models.User)
@ -265,7 +265,7 @@ func TestAPIOrgRepos(t *testing.T) {
}
func TestAPIGetRepoByIDUnauthorized(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 4}).(*models.User)
session := loginUser(t, user.Name)
token := getTokenForLoggedInUser(t, session)
@ -286,7 +286,7 @@ func TestAPIRepoMigrate(t *testing.T) {
{ctxUserID: 2, userID: 6, cloneURL: "https://github.com/go-gitea/git.git", repoName: "git-bad-org", expectedStatus: http.StatusForbidden},
}
prepareTestEnv(t)
defer prepareTestEnv(t)()
for _, testCase := range testCases {
user := models.AssertExistsAndLoadBean(t, &models.User{ID: testCase.ctxUserID}).(*models.User)
session := loginUser(t, user.Name)
@ -351,7 +351,7 @@ func TestAPIOrgRepoCreate(t *testing.T) {
{ctxUserID: 28, orgName: "user6", repoName: "repo-not-creator", expectedStatus: http.StatusForbidden},
}
prepareTestEnv(t)
defer prepareTestEnv(t)()
for _, testCase := range testCases {
user := models.AssertExistsAndLoadBean(t, &models.User{ID: testCase.ctxUserID}).(*models.User)
session := loginUser(t, user.Name)

2
integrations/api_repo_topic_test.go

@ -16,7 +16,7 @@ import (
)
func TestAPIRepoTopic(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user2 := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) // owner of repo2
user3 := models.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User) // owner of repo3
user4 := models.AssertExistsAndLoadBean(t, &models.User{ID: 4}).(*models.User) // write access to repo 3

4
integrations/api_team_test.go

@ -18,7 +18,7 @@ import (
)
func TestAPITeam(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
teamUser := models.AssertExistsAndLoadBean(t, &models.TeamUser{}).(*models.TeamUser)
team := models.AssertExistsAndLoadBean(t, &models.Team{ID: teamUser.TeamID}).(*models.Team)
@ -122,7 +122,7 @@ type TeamSearchResults struct {
}
func TestAPITeamSearch(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
org := models.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User)

2
integrations/api_team_user_test.go

@ -16,7 +16,7 @@ import (
)
func TestAPITeamUser(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
normalUsername := "user2"
session := loginUser(t, normalUsername)

4
integrations/api_token_test.go

@ -14,7 +14,7 @@ import (
// TestAPICreateAndDeleteToken tests that token that was just created can be deleted
func TestAPICreateAndDeleteToken(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
req := NewRequestWithJSON(t, "POST", "/api/v1/users/user1/tokens", map[string]string{
@ -41,7 +41,7 @@ func TestAPICreateAndDeleteToken(t *testing.T) {
// TestAPIDeleteMissingToken ensures that error is thrown when token not found
func TestAPIDeleteMissingToken(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
req := NewRequestf(t, "DELETE", "/api/v1/users/user1/tokens/%d", models.NonexistentID)

2
integrations/api_user_heatmap_test.go

@ -15,7 +15,7 @@ import (
)
func TestUserHeatmap(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
adminUsername := "user1"
normalUsername := "user2"
session := loginUser(t, adminUsername)

4
integrations/api_user_orgs_test.go

@ -16,7 +16,7 @@ import (
)
func TestUserOrgs(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
adminUsername := "user1"
normalUsername := "user2"
session := loginUser(t, adminUsername)
@ -44,7 +44,7 @@ func TestUserOrgs(t *testing.T) {
}
func TestMyOrgs(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
normalUsername := "user2"
session := loginUser(t, normalUsername)

4
integrations/api_user_search_test.go

@ -19,7 +19,7 @@ type SearchResults struct {
}
func TestAPIUserSearchLoggedIn(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
adminUsername := "user1"
session := loginUser(t, adminUsername)
token := getTokenForLoggedInUser(t, session)
@ -37,7 +37,7 @@ func TestAPIUserSearchLoggedIn(t *testing.T) {
}
func TestAPIUserSearchNotLoggedIn(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
query := "user2"
req := NewRequestf(t, "GET", "/api/v1/users/search?q=%s", query)
resp := MakeRequest(t, req, http.StatusOK)

8
integrations/auth_ldap_test.go

@ -124,7 +124,7 @@ func TestLDAPUserSignin(t *testing.T) {
t.Skip()
return
}
prepareTestEnv(t)
defer prepareTestEnv(t)()
addAuthSourceLDAP(t, "")
u := gitLDAPUsers[0]
@ -145,7 +145,7 @@ func TestLDAPUserSync(t *testing.T) {
t.Skip()
return
}
prepareTestEnv(t)
defer prepareTestEnv(t)()
addAuthSourceLDAP(t, "")
models.SyncExternalUsers()
@ -191,7 +191,7 @@ func TestLDAPUserSigninFailed(t *testing.T) {
t.Skip()
return
}
prepareTestEnv(t)
defer prepareTestEnv(t)()
addAuthSourceLDAP(t, "")
u := otherLDAPUsers[0]
@ -204,7 +204,7 @@ func TestLDAPUserSSHKeySync(t *testing.T) {
t.Skip()
return
}
prepareTestEnv(t)
defer prepareTestEnv(t)()
addAuthSourceLDAP(t, "sshPublicKey")
models.SyncExternalUsers()

6
integrations/branches_test.go

@ -15,7 +15,7 @@ import (
)
func TestViewBranches(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequest(t, "GET", "/user2/repo1/branches")
resp := MakeRequest(t, req, http.StatusOK)
@ -26,13 +26,13 @@ func TestViewBranches(t *testing.T) {
}
func TestDeleteBranch(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
deleteBranch(t)
}
func TestUndoDeleteBranch(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
deleteBranch(t)
htmlDoc, name := branchAction(t, ".undo-button")

2
integrations/change_default_branch_test.go

@ -13,7 +13,7 @@ import (
)
func TestChangeDefaultBranch(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)

2
integrations/cors_test.go

@ -12,7 +12,7 @@ import (
)
func TestCORSNotSet(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequestf(t, "GET", "/api/v1/version")
session := loginUser(t, "user2")
resp := session.MakeRequest(t, req, http.StatusOK)

6
integrations/create_no_session_test.go

@ -52,7 +52,7 @@ func sessionFileExist(t *testing.T, tmpDir, sessionID string) bool {
}
func TestSessionFileCreation(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
oldSessionConfig := setting.SessionConfig.ProviderConfig
defer func() {
@ -86,7 +86,7 @@ func TestSessionFileCreation(t *testing.T) {
routes.RegisterRoutes(mac)
t.Run("NoSessionOnViewIssue", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
req := NewRequest(t, "GET", "/user2/repo1/issues/1")
resp := MakeRequest(t, req, http.StatusOK)
@ -96,7 +96,7 @@ func TestSessionFileCreation(t *testing.T) {
assert.False(t, sessionFileExist(t, tmpDir, sessionID))
})
t.Run("CreateSessionOnLogin", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
req := NewRequest(t, "GET", "/user/login")
resp := MakeRequest(t, req, http.StatusOK)

6
integrations/delete_user_test.go

@ -25,7 +25,7 @@ func assertUserDeleted(t *testing.T, userID int64) {
}
func TestAdminDeleteUser(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
session := loginUser(t, "user1")
@ -40,7 +40,7 @@ func TestAdminDeleteUser(t *testing.T) {
}
func TestUserDeleteAccount(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
session := loginUser(t, "user8")
csrf := GetCSRF(t, session, "/user/settings/account")
@ -55,7 +55,7 @@ func TestUserDeleteAccount(t *testing.T) {
}
func TestUserDeleteAccountStillOwnRepos(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
session := loginUser(t, "user2")
csrf := GetCSRF(t, session, "/user/settings/account")

4
integrations/download_test.go

@ -12,7 +12,7 @@ import (
)
func TestDownloadByID(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
session := loginUser(t, "user2")
@ -24,7 +24,7 @@ func TestDownloadByID(t *testing.T) {
}
func TestDownloadByIDMedia(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
session := loginUser(t, "user2")

2
integrations/empty_repo_test.go

@ -12,7 +12,7 @@ import (
)
func TestEmptyRepo(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
subpaths := []string{
"commits/master",
"raw/foo",

2
integrations/explore_repos_test.go

@ -10,7 +10,7 @@ import (
)
func TestExploreRepos(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequest(t, "GET", "/explore/repos")
MakeRequest(t, req, http.StatusOK)

22
integrations/git_test.go

@ -43,7 +43,7 @@ func testGit(t *testing.T, u *url.URL) {
forkedUserCtx := NewAPITestContext(t, "user4", "repo1")
t.Run("HTTP", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
ensureAnonymousClone(t, u)
httpContext := baseAPITestContext
httpContext.Reponame = "repo-tmp-17"
@ -77,7 +77,7 @@ func testGit(t *testing.T, u *url.URL) {
})
})
t.Run("SSH", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
sshContext := baseAPITestContext
sshContext.Reponame = "repo-tmp-18"
keyname := "my-testing-key"
@ -127,7 +127,7 @@ func ensureAnonymousClone(t *testing.T, u *url.URL) {
func standardCommitAndPushTest(t *testing.T, dstPath string) (little, big string) {
t.Run("Standard", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
little, big = commitAndPushTest(t, dstPath, "data-file-")
})
return
@ -135,7 +135,7 @@ func standardCommitAndPushTest(t *testing.T, dstPath string) (little, big string
func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS string) {
t.Run("LFS", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
setting.CheckLFSVersion()
if !setting.LFS.StartServer {
t.Skip()
@ -168,7 +168,7 @@ func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS strin
littleLFS, bigLFS = commitAndPushTest(t, dstPath, prefix)
t.Run("Locks", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
lockTest(t, dstPath)
})
})
@ -177,9 +177,9 @@ func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS strin
func commitAndPushTest(t *testing.T, dstPath, prefix string) (little, big string) {
t.Run("PushCommit", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
t.Run("Little", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
little = doCommitAndPush(t, littleSize, dstPath, prefix)
})
t.Run("Big", func(t *testing.T) {
@ -187,7 +187,7 @@ func commitAndPushTest(t *testing.T, dstPath, prefix string) (little, big string
t.Skip("Skipping test in short mode.")
return
}
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
big = doCommitAndPush(t, bigSize, dstPath, prefix)
})
})
@ -196,7 +196,7 @@ func commitAndPushTest(t *testing.T, dstPath, prefix string) (little, big string
func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS string) {
t.Run("Raw", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
username := ctx.Username
reponame := ctx.Reponame
@ -232,7 +232,7 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s
func mediaTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS string) {
t.Run("Media", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
username := ctx.Username
reponame := ctx.Reponame
@ -331,7 +331,7 @@ func generateCommitWithNewData(size int, repoPath, email, fullName, prefix strin
func doBranchProtectPRMerge(baseCtx *APITestContext, dstPath string) func(t *testing.T) {
return func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
t.Run("CreateBranchProtected", doGitCreateBranch(dstPath, "protected"))
t.Run("PushProtectedBranch", doGitPushTestRepository(dstPath, "origin", "protected"))

24
integrations/gpg_git_test.go

@ -66,7 +66,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("Unsigned-Initial", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-unsigned")
t.Run("CreateRepository", doAPICreateRepository(testCtx, false))
t.Run("CheckMasterBranchUnsigned", doAPIGetBranch(testCtx, "master", func(t *testing.T, branch api.Branch) {
@ -90,7 +90,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("Unsigned-Initial-CRUD-ParentSigned", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-unsigned")
t.Run("CreateCRUDFile-ParentSigned", crudActionCreateFile(
t, testCtx, user, "master", "parentsigned", "signed-parent.txt", func(t *testing.T, response api.FileResponse) {
@ -107,7 +107,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("Unsigned-Initial-CRUD-Never", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-unsigned")
t.Run("CreateCRUDFile-Never", crudActionCreateFile(
t, testCtx, user, "parentsigned", "parentsigned-never", "unsigned-never2.txt", func(t *testing.T, response api.FileResponse) {
@ -120,7 +120,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("Unsigned-Initial-CRUD-Always", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-unsigned")
t.Run("CreateCRUDFile-Always", crudActionCreateFile(
t, testCtx, user, "master", "always", "signed-always.txt", func(t *testing.T, response api.FileResponse) {
@ -139,7 +139,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("Unsigned-Initial-CRUD-ParentSigned", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-unsigned")
t.Run("CreateCRUDFile-Always-ParentSigned", crudActionCreateFile(
t, testCtx, user, "always", "always-parentsigned", "signed-always-parentsigned.txt", func(t *testing.T, response api.FileResponse) {
@ -153,7 +153,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("AlwaysSign-Initial", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-always")
t.Run("CreateRepository", doAPICreateRepository(testCtx, false))
t.Run("CheckMasterBranchSigned", doAPIGetBranch(testCtx, "master", func(t *testing.T, branch api.Branch) {
@ -169,7 +169,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("AlwaysSign-Initial-CRUD-Never", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-always")
t.Run("CreateCRUDFile-Never", crudActionCreateFile(
t, testCtx, user, "master", "never", "unsigned-never.txt", func(t *testing.T, response api.FileResponse) {
@ -182,7 +182,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("AlwaysSign-Initial-CRUD-ParentSigned-On-Always", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-always")
t.Run("CreateCRUDFile-ParentSigned", crudActionCreateFile(
t, testCtx, user, "master", "parentsigned", "signed-parent.txt", func(t *testing.T, response api.FileResponse) {
@ -196,7 +196,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("AlwaysSign-Initial-CRUD-Always", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-always")
t.Run("CreateCRUDFile-Always", crudActionCreateFile(
t, testCtx, user, "master", "always", "signed-always.txt", func(t *testing.T, response api.FileResponse) {
@ -212,7 +212,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("UnsignedMerging", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-unsigned")
var err error
t.Run("CreatePullRequest", func(t *testing.T) {
@ -233,7 +233,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("BaseSignedMerging", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-unsigned")
var err error
t.Run("CreatePullRequest", func(t *testing.T) {
@ -254,7 +254,7 @@ func TestGPGGit(t *testing.T) {
u.Path = baseAPITestContext.GitPath()
t.Run("CommitsSignedMerging", func(t *testing.T) {
PrintCurrentTest(t)
defer PrintCurrentTest(t)()
testCtx := NewAPITestContext(t, username, "initial-unsigned")
var err error
t.Run("CreatePullRequest", func(t *testing.T) {

5
integrations/integration_test.go

@ -173,19 +173,20 @@ func initIntegrationTest() {
routers.GlobalInit()
}
func prepareTestEnv(t testing.TB, skip ...int) {
func prepareTestEnv(t testing.TB, skip ...int) func() {
t.Helper()
ourSkip := 2
if len(skip) > 0 {
ourSkip += skip[0]
}
PrintCurrentTest(t, ourSkip)
deferFn := PrintCurrentTest(t, ourSkip)
assert.NoError(t, models.LoadFixtures())
assert.NoError(t, os.RemoveAll(setting.RepoRootPath))
assert.NoError(t, os.RemoveAll(models.LocalCopyPath()))
assert.NoError(t, com.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"),
setting.RepoRootPath))
return deferFn
}
type TestSession struct {

14
integrations/issue_test.go

@ -49,14 +49,14 @@ func assertMatch(t testing.TB, issue *models.Issue, keyword string) {
}
func TestNoLoginViewIssues(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
req := NewRequest(t, "GET", "/user2/repo1/issues")
MakeRequest(t, req, http.StatusOK)
}
func TestViewIssuesSortByType(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 1}).(*models.User)
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
@ -84,7 +84,7 @@ func TestViewIssuesSortByType(t *testing.T) {
}
func TestViewIssuesKeyword(t *testing.T) {
prepareTestEnv(t)
defer prepareTestEnv(t)()
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
@ -104,7 +104,7 @@ func TestViewIssuesKeyword(t *testing.T) {
}