-
Notifications
You must be signed in to change notification settings - Fork 547
/
lambda_function_urls_test.go
57 lines (44 loc) · 1.45 KB
/
lambda_function_urls_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
package events
import (
"encoding/json"
"io/ioutil" //nolint: staticcheck
"testing"
"github.com/stretchr/testify/assert"
)
func TestLambdaFunctionURLResponseMarshaling(t *testing.T) {
// read json from file
inputJSON, err := ioutil.ReadFile("./testdata/lambda-urls-response.json")
if err != nil {
t.Errorf("could not open test file. details: %v", err)
}
// de-serialize into Go object
var inputEvent LambdaFunctionURLResponse
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)
}
assert.JSONEq(t, string(inputJSON), string(outputJSON))
}
func TestLambdaFunctionURLRequestMarshaling(t *testing.T) {
// read json from file
inputJSON, err := ioutil.ReadFile("./testdata/lambda-urls-request.json")
if err != nil {
t.Errorf("could not open test file. details: %v", err)
}
// de-serialize into Go object
var inputEvent LambdaFunctionURLRequest
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)
}
assert.JSONEq(t, string(inputJSON), string(outputJSON))
}