test(context): cover non-ErrNotMultipart branch in initFormCache

This commit is contained in:
RubenPari 2026-08-11 23:02:01 +02:00
parent 0aae1ab6c9
commit f74cad00a7

View File

@ -928,6 +928,16 @@ func TestContextPostFormOnEmptyRequest(t *testing.T) {
})
}
func TestContextPostFormMalformedMultipart(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest(http.MethodPost, "/", strings.NewReader("not multipart"))
c.Request.Header.Set("Content-Type", "multipart/form-data; boundary=xxx")
assert.NotPanics(t, func() {
assert.Empty(t, c.PostForm("NoKey"))
})
}
func TestContextQueryAndPostForm(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
body := strings.NewReader("foo=bar&page=11&both=&foo=second")