Skip to content

Commit

Permalink
feat: improve data race tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerwill90 committed Nov 21, 2024
1 parent 07e1b92 commit 724783e
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions fox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5711,14 +5711,22 @@ func TestDataRace(t *testing.T) {
var wg sync.WaitGroup
start, wait := atomicSync()

h := HandlerFunc(func(c Context) {})
newH := HandlerFunc(func(c Context) {})
h := HandlerFunc(func(c Context) {
c.Pattern()
for range c.Params() {
}
})
newH := HandlerFunc(func(c Context) {
c.Pattern()
for range c.Params() {
}
})

f := New()

w := new(mockResponseWriter)

wg.Add(len(githubAPI) * 3)
wg.Add(len(githubAPI) * 4)
for _, rte := range githubAPI {
go func(method, route string) {
wait()
Expand Down Expand Up @@ -5752,11 +5760,22 @@ func TestDataRace(t *testing.T) {
}
}(rte.method, rte.path)

go func() {
wait()
defer wg.Done()
for route := range iterutil.Right(f.Iter().All()) {
route.Pattern()
for range route.Annotations() {

}
}
}()

go func(method, route string) {
wait()
defer wg.Done()
req := httptest.NewRequest(method, route, nil)
f.ServeHTTP(w, req)
wg.Done()
}(rte.method, rte.path)
}

Expand Down

0 comments on commit 724783e

Please sign in to comment.