@@ -9,27 +9,41 @@ import (
9
9
)
10
10
11
11
func TestLexEventMarshaling (t * testing.T ) {
12
- tests := []struct {
13
- filePath string
14
- }{{"./testdata/lex-response.json" }, {"./testdata/lex-event.json" }}
12
+ inputJSON := test .ReadJSONFromFile (t , "./testdata/lex-event.json" )
15
13
16
- for _ , te := range tests {
17
- inputJSON := test .ReadJSONFromFile (t , te .filePath )
14
+ var inputEvent LexEvent
15
+ if err := json .Unmarshal (inputJSON , & inputEvent ); err != nil {
16
+ t .Errorf ("could not unmarshal event. details: %v" , err )
17
+ }
18
18
19
- var inputEvent LexEvent
20
- if err := json . Unmarshal ( inputJSON , & inputEvent ); err != nil {
21
- t .Errorf ("could not unmarshal event. details: %v" , err )
22
- }
19
+ outputJSON , err := json . Marshal ( inputEvent )
20
+ if err != nil {
21
+ t .Errorf ("could not marshal event. details: %v" , err )
22
+ }
23
23
24
- outputJSON , err := json .Marshal (inputEvent )
25
- if err != nil {
26
- t .Errorf ("could not marshal event. details: %v" , err )
27
- }
24
+ assert .JSONEq (t , string (inputJSON ), string (outputJSON ))
25
+ }
28
26
29
- assert .JSONEq (t , string (inputJSON ), string (outputJSON ))
27
+ func TestLexResponseMarshaling (t * testing.T ) {
28
+ inputJSON := test .ReadJSONFromFile (t , "./testdata/lex-response.json" )
29
+
30
+ var inputEvent LexResponse
31
+ if err := json .Unmarshal (inputJSON , & inputEvent ); err != nil {
32
+ t .Errorf ("could not unmarshal event. details: %v" , err )
30
33
}
34
+
35
+ outputJSON , err := json .Marshal (inputEvent )
36
+ if err != nil {
37
+ t .Errorf ("could not marshal event. details: %v" , err )
38
+ }
39
+
40
+ assert .JSONEq (t , string (inputJSON ), string (outputJSON ))
31
41
}
32
42
33
43
func TestLexMarshalingMalformedJson (t * testing.T ) {
34
44
test .TestMalformedJson (t , LexEvent {})
35
45
}
46
+
47
+ func TestLexResponseMalformedJson (t * testing.T ) {
48
+ test .TestMalformedJson (t , LexResponse {})
49
+ }
0 commit comments