Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
saksham-arya-z committed Nov 20, 2024
1 parent 98499b5 commit b5e8b10
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import (
"time"

"github.com/gin-contrib/sse"
"github.com/gin-gonic/gin/binding"
testdata "github.com/gin-gonic/gin/testdata/protoexample"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"

"github.com/gin-gonic/gin/binding"
testdata "github.com/gin-gonic/gin/testdata/protoexample"
)

var _ context.Context = (*Context)(nil)
Expand Down Expand Up @@ -3123,3 +3124,23 @@ func TestContextNext(t *testing.T) {
assert.True(t, exists)
assert.Equal(t, "value3", value)
}

func TestParallelHeaderWrite(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
for i := 0; i < 1000; i++ {
c.Header("key", "value")
}
}()
wg.Add(1)
go func() {
defer wg.Done()
for i := 0; i < 1000; i++ {
c.Header("key", "value")
}
}()
wg.Wait()
}

0 comments on commit b5e8b10

Please sign in to comment.