aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-12-01 00:41:49 +0800
committerGitHub <noreply@github.com>2022-12-01 00:41:49 +0800
commitb2c4870481329889a76ea2421152647d36dd8374 (patch)
tree2c38760bed01e1b2da3a36fa67917e4e60b5c252 /tests
parent67881ae99abc673954d56436730af313c93ee48f (diff)
downloadgitea-b2c4870481329889a76ea2421152647d36dd8374.tar.gz
gitea-b2c4870481329889a76ea2421152647d36dd8374.zip
Fix parallel creating commit status bug with tests (#21911)
This PR is a follow up of #21469 Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/repo_commits_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/integration/repo_commits_test.go b/tests/integration/repo_commits_test.go
index 438e1c2cc4..3840c508dc 100644
--- a/tests/integration/repo_commits_test.go
+++ b/tests/integration/repo_commits_test.go
@@ -4,9 +4,11 @@
package integration
import (
+ "fmt"
"net/http"
"net/http/httptest"
"path"
+ "sync"
"testing"
"code.gitea.io/gitea/modules/json"
@@ -114,3 +116,32 @@ func TestRepoCommitsWithStatusFailure(t *testing.T) {
func TestRepoCommitsWithStatusWarning(t *testing.T) {
doTestRepoCommitWithStatus(t, "warning", "gitea-exclamation", "yellow")
}
+
+func TestRepoCommitsStatusParallel(t *testing.T) {
+ defer tests.PrepareTestEnv(t)()
+
+ session := loginUser(t, "user2")
+
+ // Request repository commits page
+ req := NewRequest(t, "GET", "/user2/repo1/commits/branch/master")
+ resp := session.MakeRequest(t, req, http.StatusOK)
+
+ doc := NewHTMLParser(t, resp.Body)
+ // Get first commit URL
+ commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Attr("href")
+ assert.True(t, exists)
+ assert.NotEmpty(t, commitURL)
+
+ var wg sync.WaitGroup
+ for i := 0; i < 10; i++ {
+ wg.Add(1)
+ go func(t *testing.T, i int) {
+ t.Run(fmt.Sprintf("ParallelCreateStatus_%d", i), func(t *testing.T) {
+ runBody := doAPICreateCommitStatus(NewAPITestContext(t, "user2", "repo1"), path.Base(commitURL), api.CommitStatusState("pending"))
+ runBody(t)
+ wg.Done()
+ })
+ }(t, i)
+ }
+ wg.Wait()
+}