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.
This commit is contained in:
Renan Pimentel 2026-10-06 20:56:59 -03:00
parent 43fe48e8a0
commit 441ee408b1

View File

@ -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)
}