MCPcopy
hub / github.com/gin-gonic/gin / TestSaveUploadedCreateFailed

Function TestSaveUploadedCreateFailed

context_test.go:217–233  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

215}
216
217func TestSaveUploadedCreateFailed(t *testing.T) {
218 buf := new(bytes.Buffer)
219 mw := multipart.NewWriter(buf)
220 w, err := mw.CreateFormFile("file", "test")
221 require.NoError(t, err)
222 _, err = w.Write([]byte("test"))
223 require.NoError(t, err)
224 mw.Close()
225 c, _ := CreateTestContext(httptest.NewRecorder())
226 c.Request, _ = http.NewRequest(http.MethodPost, "/", buf)
227 c.Request.Header.Set("Content-Type", mw.FormDataContentType())
228 f, err := c.FormFile("file")
229 require.NoError(t, err)
230 assert.Equal(t, "test", f.Filename)
231
232 require.Error(t, c.SaveUploadedFile(f, "/"))
233}
234
235func TestSaveUploadedFileWithPermission(t *testing.T) {
236 buf := new(bytes.Buffer)

Callers

nothing calls this directly

Calls 7

CreateTestContextFunction · 0.85
CloseMethod · 0.80
SetMethod · 0.80
FormFileMethod · 0.80
SaveUploadedFileMethod · 0.80
WriteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected