Skip to content

Commit 6772121

Browse files
authored
Merge pull request #4498 from gofiber/fix/v2-parser-decoder-global-leak
test(ctx): restore global parser decoder after SetParserDecoder tests (fixes shuffle/-race flakes)
2 parents 79d3444 + 396416e commit 6772121

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

ctx_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ func Test_Ctx_BodyParser_InvalidRequestData(t *testing.T) {
680680
}
681681

682682
func Test_Ctx_BodyParser_IndexTooLarge(t *testing.T) {
683-
defer SetParserDecoder(ParserConfig{IgnoreUnknownKeys: true})
683+
defer SetParserDecoder(ParserConfig{IgnoreUnknownKeys: true, ZeroEmpty: true})
684684
SetParserDecoder(ParserConfig{IgnoreUnknownKeys: false})
685685
type RequestBody struct {
686686
NestedContent []*struct {
@@ -741,6 +741,9 @@ func Test_Ctx_BodyParser_WithSetParserDecoder(t *testing.T) {
741741
Converter: timeConverter,
742742
}
743743

744+
// restore the package-default decoder afterwards so this global change does
745+
// not leak into other (parallel) parser tests
746+
defer SetParserDecoder(ParserConfig{IgnoreUnknownKeys: true, ZeroEmpty: true})
744747
SetParserDecoder(ParserConfig{
745748
IgnoreUnknownKeys: true,
746749
ParserType: []ParserType{customTime},
@@ -4906,6 +4909,9 @@ func Test_Ctx_QueryParser_WithSetParserDecoder(t *testing.T) {
49064909
Converter: nonRFCConverter,
49074910
}
49084911

4912+
// restore the package-default decoder afterwards so this global change does
4913+
// not leak into other (parallel) parser tests
4914+
defer SetParserDecoder(ParserConfig{IgnoreUnknownKeys: true, ZeroEmpty: true})
49094915
SetParserDecoder(ParserConfig{
49104916
IgnoreUnknownKeys: true,
49114917
ParserType: []ParserType{nonRFCTime},
@@ -5261,6 +5267,9 @@ func Test_Ctx_ReqHeaderParser_WithSetParserDecoder(t *testing.T) {
52615267
Converter: nonRFCConverter,
52625268
}
52635269

5270+
// restore the package-default decoder afterwards so this global change does
5271+
// not leak into other (parallel) parser tests
5272+
defer SetParserDecoder(ParserConfig{IgnoreUnknownKeys: true, ZeroEmpty: true})
52645273
SetParserDecoder(ParserConfig{
52655274
IgnoreUnknownKeys: true,
52665275
ParserType: []ParserType{nonRFCTime},

0 commit comments

Comments
 (0)