From 441ee408b18a81a3e84f967c99c50eee10fb96e1 Mon Sep 17 00:00:00 2001 From: Renan Pimentel Date: Tue, 6 Oct 2026 20:56:59 -0300 Subject: [PATCH] test(binding): check bad bodies with the binding under test testBodyBinding and testBodyBindingFail receive the binding under test as `b`, but their second half bound the bad body with JSON.Bind. For XML, TOML, YAML and BSON this meant the validation case never ran through the binding being tested. As a result, making xmlBinding or tomlBinding ignore decode errors and skip validate() (`err != nil` -> `err == nil` in decodeXML/decodeTOML) kept the whole binding package green. With b.Bind, TestBindingXML, TestBindingXMLFail, TestBindingTOML and TestBindingTOMLFail fail on that change and pass on master. --- binding/binding_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binding/binding_test.go b/binding/binding_test.go index f90488cd..87393bfa 100644 --- a/binding/binding_test.go +++ b/binding/binding_test.go @@ -1225,7 +1225,7 @@ func testBodyBinding(t *testing.T, b Binding, name, path, badPath, body, badBody obj = FooStruct{} req = requestWithBody(http.MethodPost, badPath, badBody) - err = JSON.Bind(req, &obj) + err = b.Bind(req, &obj) require.Error(t, err) } @@ -1336,7 +1336,7 @@ func testBodyBindingFail(t *testing.T, b Binding, name, path, badPath, body, bad obj = FooStruct{} req = requestWithBody(http.MethodPost, badPath, badBody) - err = JSON.Bind(req, &obj) + err = b.Bind(req, &obj) require.Error(t, err) }