Skip to content

Commit a5afe43

Browse files
committed
Unit test the WithUseNumber option
1 parent 9e33b71 commit a5afe43

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lambda/handler_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"io"
1111
"io/ioutil" //nolint: staticcheck
12+
"reflect"
1213
"strings"
1314
"testing"
1415
"time"
@@ -309,6 +310,33 @@ func TestInvokes(t *testing.T) {
309310
},
310311
options: []Option{WithSetIndent(">>", " ")},
311312
},
313+
{
314+
name: "WithUseNumber(true) results in json.Number instead of float64 when decoding to an interface{}",
315+
input: `19.99`,
316+
expected: expected{`"Number"`, nil},
317+
handler: func(event interface{}) (string, error) {
318+
return reflect.TypeOf(event).Name(), nil
319+
},
320+
options: []Option{WithUseNumber(true)},
321+
},
322+
{
323+
name: "WithUseNumber(false)",
324+
input: `19.99`,
325+
expected: expected{`"float64"`, nil},
326+
handler: func(event interface{}) (string, error) {
327+
return reflect.TypeOf(event).Name(), nil
328+
},
329+
options: []Option{WithUseNumber(false)},
330+
},
331+
{
332+
name: "No decoder options provided is the same as WithUseNumber(false)",
333+
input: `19.99`,
334+
expected: expected{`"float64"`, nil},
335+
handler: func(event interface{}) (string, error) {
336+
return reflect.TypeOf(event).Name(), nil
337+
},
338+
options: []Option{},
339+
},
312340
{
313341
name: "bytes are base64 encoded strings",
314342
input: `"aGVsbG8="`,

0 commit comments

Comments
 (0)