-
Notifications
You must be signed in to change notification settings - Fork 560
/
Copy pathevent_test.go
38 lines (29 loc) · 915 Bytes
/
event_test.go
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
37
38
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
package cfn
import (
"encoding/json"
"io/ioutil" //nolint: staticcheck
"testing"
"github.com/aws/aws-lambda-go/events/test"
)
func TestCloudFormationEventMarshaling(t *testing.T) {
// read json from file
inputJSON, err := ioutil.ReadFile("./testdata/cloudformation-event.json")
if err != nil {
t.Errorf("could not open test file. details: %v", err)
}
// de-serialize into Event
var inputEvent Event
if err := json.Unmarshal(inputJSON, &inputEvent); err != nil {
t.Errorf("could not unmarshal event. details: %v", err)
}
// serialize to json
outputJSON, err := json.Marshal(inputEvent)
if err != nil {
t.Errorf("could not marshal event. details: %v", err)
}
test.AssertJsonsEqual(t, inputJSON, outputJSON)
}
func TestCloudFormationMarshalingMalformedJson(t *testing.T) {
test.TestMalformedJson(t, Event{})
}