From f0c5d1ecaf30033ff91e5c739e329cd624b84c3e Mon Sep 17 00:00:00 2001 From: chuanye-gao Date: Sun, 27 Sep 2026 22:57:37 +0800 Subject: [PATCH] ci: run the test suite with the jsoniter build tag The jsoniter build tag is documented in docs/doc.md but was never covered by the CI matrix, so codec/json/jsoniter.go was neither compiled nor tested. Add it alongside the existing sonic and go_json entries. TestContextBindRequestTooLarge now expects a generic 400 for jsoniter: like goccy/go-json, it does not propagate http.MaxBytesError, so MustBindWith cannot detect it via errors.As. --- .github/workflows/gin.yml | 1 + context_test.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gin.yml b/.github/workflows/gin.yml index d0f42d09..0abd6f8e 100644 --- a/.github/workflows/gin.yml +++ b/.github/workflows/gin.yml @@ -43,6 +43,7 @@ jobs: "-tags nomsgpack", '--ldflags="-checklinkname=0" -tags sonic', "-tags go_json", + "-tags jsoniter", "-race", ] include: diff --git a/context_test.go b/context_test.go index b82e04d5..cefa5081 100644 --- a/context_test.go +++ b/context_test.go @@ -2321,12 +2321,12 @@ func TestContextContentType(t *testing.T) { } func TestContextBindRequestTooLarge(t *testing.T) { - // When using go-json as JSON encoder, they do not propagate the http.MaxBytesError error - // The response will fail with a generic 400 instead of 413 + // When using go-json or jsoniter as JSON encoder, they do not propagate the + // http.MaxBytesError error. The response will fail with a generic 400 instead of 413. // https://github.com/goccy/go-json/issues/485 var expectedCode int switch json.Package { - case "github.com/goccy/go-json": + case "github.com/goccy/go-json", "github.com/json-iterator/go": expectedCode = http.StatusBadRequest default: expectedCode = http.StatusRequestEntityTooLarge