From f74cad00a7e7cb906e3bd0bb312469aa5860211a Mon Sep 17 00:00:00 2001 From: RubenPari Date: Tue, 11 Aug 2026 23:02:01 +0200 Subject: [PATCH] test(context): cover non-ErrNotMultipart branch in initFormCache --- context_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/context_test.go b/context_test.go index 7d35a441..efdd0db4 100644 --- a/context_test.go +++ b/context_test.go @@ -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")