add test case

fix lint
This commit is contained in:
Saksham Arya 2024-11-20 16:18:37 +05:30
parent c2e744e158
commit cd86308ad1
1 changed files with 22 additions and 2 deletions

View File

@ -166,7 +166,7 @@ func TestSaveUploadedFileWithPermission(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
mw.Close() mw.Close()
c, _ := CreateTestContext(httptest.NewRecorder()) c, _ := CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest("POST", "/", buf) c.Request, _ = http.NewRequest(http.MethodPost, "/", buf)
c.Request.Header.Set("Content-Type", mw.FormDataContentType()) c.Request.Header.Set("Content-Type", mw.FormDataContentType())
f, err := c.FormFile("file") f, err := c.FormFile("file")
require.NoError(t, err) require.NoError(t, err)
@ -187,7 +187,7 @@ func TestSaveUploadedFileWithPermissionFailed(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
mw.Close() mw.Close()
c, _ := CreateTestContext(httptest.NewRecorder()) c, _ := CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest("POST", "/", buf) c.Request, _ = http.NewRequest(http.MethodPost, "/", buf)
c.Request.Header.Set("Content-Type", mw.FormDataContentType()) c.Request.Header.Set("Content-Type", mw.FormDataContentType())
f, err := c.FormFile("file") f, err := c.FormFile("file")
require.NoError(t, err) require.NoError(t, err)
@ -3123,3 +3123,23 @@ func TestContextNext(t *testing.T) {
assert.True(t, exists) assert.True(t, exists)
assert.Equal(t, "value3", value) 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()
}