mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-24 17:14:41 +00:00
test: speed up tests, fix transaction bug (#39030)
Speed up tests: `make test-backend` 103s to 37s, `make test-integration` 908s to 852s. Most of it is a detached system notice insert blocking on the SQLite write lock until the busy timeout expired, and `ExternalServiceHTTP` re-probing on every call with an untimed `http.Get`. - fixed one correctness bug with nested transactions: files were deleted while the outer transaction was open, so a later failure could roll the database back with the files gone - git push branch counts were far above the hook batch size - Fix makefile dependencies so running tests and lint work in fresh worktrees. --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -29,7 +29,7 @@ func TestGitPush(t *testing.T) {
|
||||
func testGitPush(t *testing.T, u *url.URL) {
|
||||
t.Run("Push branches at once", func(t *testing.T) {
|
||||
runTestGitPush(t, u, func(t *testing.T, gitPath string) (pushed, deleted []string) {
|
||||
for i := range 100 {
|
||||
for i := range 10 {
|
||||
branchName := fmt.Sprintf("branch-%d", i)
|
||||
pushed = append(pushed, branchName)
|
||||
doGitCreateBranch(gitPath, branchName)(t)
|
||||
@@ -81,7 +81,7 @@ func testGitPush(t *testing.T, u *url.URL) {
|
||||
|
||||
t.Run("Push branches one by one", func(t *testing.T) {
|
||||
runTestGitPush(t, u, func(t *testing.T, gitPath string) (pushed, deleted []string) {
|
||||
for i := range 100 {
|
||||
for i := range 10 {
|
||||
branchName := fmt.Sprintf("branch-%d", i)
|
||||
doGitCreateBranch(gitPath, branchName)(t)
|
||||
doGitPushTestRepository(gitPath, "origin", branchName)(t)
|
||||
@@ -107,14 +107,14 @@ func testGitPush(t *testing.T, u *url.URL) {
|
||||
doGitPushTestRepository(gitPath, "origin", "master")(t) // make sure master is the default branch instead of a branch we are going to delete
|
||||
pushed = append(pushed, "master")
|
||||
|
||||
for i := range 100 {
|
||||
for i := range 10 {
|
||||
branchName := fmt.Sprintf("branch-%d", i)
|
||||
pushed = append(pushed, branchName)
|
||||
doGitCreateBranch(gitPath, branchName)(t)
|
||||
}
|
||||
doGitPushTestRepository(gitPath, "origin", "--all")(t)
|
||||
|
||||
for i := range 10 {
|
||||
for i := range 5 {
|
||||
branchName := fmt.Sprintf("branch-%d", i)
|
||||
doGitPushTestRepository(gitPath, "origin", "--delete", branchName)(t)
|
||||
deleted = append(deleted, branchName)
|
||||
|
||||
Reference in New Issue
Block a user