Skip to content

Commit 6d888d2

Browse files
committed
Add a concurrent test for issue creation
1 parent ca6fb00 commit 6d888d2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

integrations/issue_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
package integrations
66

77
import (
8+
"context"
9+
"fmt"
810
"net/http"
911
"path"
1012
"strconv"
1113
"strings"
14+
"sync"
1215
"testing"
1316

1417
"code.gitea.io/gitea/models"
@@ -184,3 +187,34 @@ func TestIssueCommentClose(t *testing.T) {
184187
val := htmlDoc.doc.Find(".comment-list .comments .comment .render-content p").First().Text()
185188
assert.Equal(t, "Description", val)
186189
}
190+
191+
func TestNewIssueConcurrent(t *testing.T) {
192+
193+
prepareTestEnv(t)
194+
session := loginUser(t, "user2")
195+
196+
f := func(ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup) {
197+
defer wg.Done()
198+
199+
select {
200+
case <-ctx.Done():
201+
return
202+
default:
203+
}
204+
testNewIssue(t, session, "user2", "repo1", fmt.Sprintf("Title"), "Description")
205+
if t.Failed() {
206+
cancel()
207+
return
208+
}
209+
}
210+
211+
wg := &sync.WaitGroup{}
212+
ctx, cancel := context.WithCancel(context.Background())
213+
defer cancel()
214+
215+
for i := 0; i < 1000; i++ {
216+
wg.Add(1)
217+
go f(ctx, cancel, wg)
218+
}
219+
wg.Wait()
220+
}

0 commit comments

Comments
 (0)