Skip to content

Commit 908421f

Browse files
artempankobmoffattBryan Moffatt
authored
remove dialog action from lex event (#240)
* remove dialog action from lex event * gofmt * fix type in TestLexResponseMalformedJson Co-authored-by: Bryan Moffatt <[email protected]> Co-authored-by: Bryan Moffatt <[email protected]>
1 parent af8e8ed commit 908421f

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

events/lex.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ type LexEvent struct {
1111
OutputDialogMode string `json:"outputDialogMode,omitempty"`
1212
CurrentIntent *LexCurrentIntent `json:"currentIntent,omitempty"`
1313
AlternativeIntents []LexAlternativeIntents `json:"alternativeIntents,omitempty"`
14-
DialogAction *LexDialogAction `json:"dialogAction,omitempty"`
14+
// Deprecated: the DialogAction field is never populated by Lex events
15+
DialogAction *LexDialogAction `json:"dialogAction,omitempty"`
1516
}
1617

1718
type LexBot struct {
@@ -77,5 +78,4 @@ type Attachment struct {
7778
func (h *LexEvent) Clear() {
7879
h.Bot = nil
7980
h.CurrentIntent = nil
80-
h.DialogAction = nil
8181
}

events/lex_test.go

+28-14
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,41 @@ import (
99
)
1010

1111
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")
1513

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+
}
1818

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+
}
2323

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+
}
2826

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)
3033
}
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))
3141
}
3242

3343
func TestLexMarshalingMalformedJson(t *testing.T) {
3444
test.TestMalformedJson(t, LexEvent{})
3545
}
46+
47+
func TestLexResponseMalformedJson(t *testing.T) {
48+
test.TestMalformedJson(t, LexResponse{})
49+
}

0 commit comments

Comments
 (0)