Skip to content

Commit 61a91ba

Browse files
committed
Unit test the WithDisallowUnknownFields option
1 parent a5afe43 commit 61a91ba

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lambda/handler_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,27 @@ func TestInvokes(t *testing.T) {
337337
},
338338
options: []Option{},
339339
},
340+
{
341+
name: "WithDisallowUnknownFields(true)",
342+
input: `{"Hello": "World"}`,
343+
expected: expected{"", errors.New(`json: unknown field "Hello"`)},
344+
handler: func(_ struct{}) {},
345+
options: []Option{WithDisallowUnknownFields(true)},
346+
},
347+
{
348+
name: "WithDisallowUnknownFields(false)",
349+
input: `{"Hello": "World"}`,
350+
expected: expected{`null`, nil},
351+
handler: func(_ struct{}) {},
352+
options: []Option{WithDisallowUnknownFields(false)},
353+
},
354+
{
355+
name: "No decoder options provided is the same as WithDisallowUnknownFields(false)",
356+
input: `{"Hello": "World"}`,
357+
expected: expected{`null`, nil},
358+
handler: func(_ struct{}) {},
359+
options: []Option{},
360+
},
340361
{
341362
name: "bytes are base64 encoded strings",
342363
input: `"aGVsbG8="`,

0 commit comments

Comments
 (0)