-
Notifications
You must be signed in to change notification settings - Fork 573
Expand file tree
/
Copy paths3_object_lambda_test.go
More file actions
44 lines (36 loc) · 1.14 KB
/
s3_object_lambda_test.go
File metadata and controls
44 lines (36 loc) · 1.14 KB
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
39
40
41
42
43
44
package events
import (
"encoding/json"
"testing"
"github.com/aws/aws-lambda-go/events/test"
"github.com/stretchr/testify/assert"
)
func TestS3ObjectLambdaEventMarshaling(t *testing.T) {
tests := []struct {
file string
}{
{"./testdata/s3-object-lambda-event-get-object-iam.json"},
{"./testdata/s3-object-lambda-event-get-object-assumed-role.json"},
{"./testdata/s3-object-lambda-event-head-object-iam.json"},
{"./testdata/s3-object-lambda-event-list-objects-iam.json"},
{"./testdata/s3-object-lambda-event-list-objects-v2-iam.json"},
}
for _, tc := range tests {
tc := tc
t.Run(tc.file, func(t *testing.T) {
inputJSON := test.ReadJSONFromFile(t, tc.file)
var inputEvent S3ObjectLambdaEvent
if err := json.Unmarshal(inputJSON, &inputEvent); err != nil {
t.Errorf("could not unmarshal event. details: %v", err)
}
outputJSON, err := json.Marshal(inputEvent)
if err != nil {
t.Errorf("could not marshal event. details: %v", err)
}
assert.JSONEq(t, string(inputJSON), string(outputJSON))
})
}
}
func TestS3ObjectLambdaMarshalingMalformedJson(t *testing.T) {
test.TestMalformedJson(t, S3ObjectLambdaEvent{})
}