-
Notifications
You must be signed in to change notification settings - Fork 573
Expand file tree
/
Copy pathconnect_test.go
More file actions
36 lines (27 loc) · 877 Bytes
/
connect_test.go
File metadata and controls
36 lines (27 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
package events
import (
"encoding/json"
"testing"
"github.com/aws/aws-lambda-go/events/test"
"github.com/stretchr/testify/assert"
)
func TestConnectMarshaling(t *testing.T) {
// 1. read JSON from file
inputJSON := test.ReadJSONFromFile(t, "./testdata/connect-event.json")
// 2. de-serialize into Go object
var inputEvent ConnectEvent
if err := json.Unmarshal(inputJSON, &inputEvent); err != nil {
t.Errorf("could not unmarshal event. details: %v", err)
}
// 3. serialize to JSON
outputJSON, err := json.Marshal(inputEvent)
if err != nil {
t.Errorf("could not marshal event. details: %v", err)
}
// 4. check result
assert.JSONEq(t, string(inputJSON), string(outputJSON))
}
func TestConnectMarshalingMalformedJson(t *testing.T) {
test.TestMalformedJson(t, ConnectEvent{})
}