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

Function TestSaveUploadedOpenFailed

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

Source from the content-addressed store, hash-verified

200}
201
202func TestSaveUploadedOpenFailed(t *testing.T) {
203 buf := new(bytes.Buffer)
204 mw := multipart.NewWriter(buf)
205 mw.Close()
206
207 c, _ := CreateTestContext(httptest.NewRecorder())
208 c.Request, _ = http.NewRequest(http.MethodPost, "/", buf)
209 c.Request.Header.Set("Content-Type", mw.FormDataContentType())
210
211 f := &multipart.FileHeader{
212 Filename: "file",
213 }
214 require.Error(t, c.SaveUploadedFile(f, "test"))
215}
216
217func TestSaveUploadedCreateFailed(t *testing.T) {
218 buf := new(bytes.Buffer)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected