FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lambda-runtime-init/lambda/interop/model_test.go at localstack · developer-guy/lambda-runtime-init · GitHub
developer-guy
/
lambda-runtime-init
Public
forked from
localstack/lambda-runtime-init
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
lambda-runtime-init
/
lambda
/
interop
/
model_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (54 loc) · 2.25 KB
Breadcrumbs
lambda-runtime-init
/
lambda
/
interop
/
model_test.go
Copy path
File metadata and controls
66 lines (54 loc) · 2.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
58
59
60
61
62
63
64
65
66
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package
interop
import
(
"fmt"
"testing"
"go.amzn.com/lambda/fatalerror"
"github.com/stretchr/testify/assert"
)
func
TestMergeSubscriptionMetrics
(
t
*
testing.
T
) {
logsAPIMetrics
:=
map
[
string
]
int
{
"server_error"
:
1
,
"client_error"
:
2
,
}
telemetryAPIMetrics
:=
map
[
string
]
int
{
"server_error"
:
1
,
"success"
:
5
,
}
metrics
:=
MergeSubscriptionMetrics
(
logsAPIMetrics
,
telemetryAPIMetrics
)
assert
.
Equal
(
t
,
5
,
metrics
[
"success"
])
assert
.
Equal
(
t
,
2
,
metrics
[
"server_error"
])
assert
.
Equal
(
t
,
2
,
metrics
[
"client_error"
])
}
func
TestGetErrorResponseWithFormattedErrorMessageWithoutInvokeRequestId
(
t
*
testing.
T
) {
errorType
:=
fatalerror
.
RuntimeExit
errorMessage
:=
fmt
.
Errorf
(
"Divided by 0"
)
expectedMsg
:=
fmt
.
Sprintf
(
`Error: %s`
,
errorMessage
)
expectedJSON
:=
fmt
.
Sprintf
(
`{"errorType": "%s", "errorMessage": "%s"}`
,
string
(
errorType
),
expectedMsg
)
actual
:=
GetErrorResponseWithFormattedErrorMessage
(
errorType
,
errorMessage
,
""
)
assert
.
Equal
(
t
,
errorType
,
actual
.
FunctionError
.
Type
)
assert
.
Equal
(
t
,
expectedMsg
,
actual
.
FunctionError
.
Message
)
assert
.
JSONEq
(
t
,
expectedJSON
,
string
(
actual
.
Payload
))
}
func
TestGetErrorResponseWithFormattedErrorMessageWithInvokeRequestId
(
t
*
testing.
T
) {
errorType
:=
fatalerror
.
RuntimeExit
errorMessage
:=
fmt
.
Errorf
(
"Divided by 0"
)
invokeID
:=
"invoke-id"
expectedMsg
:=
fmt
.
Sprintf
(
`RequestId: %s Error: %s`
,
invokeID
,
errorMessage
)
expectedJSON
:=
fmt
.
Sprintf
(
`{"errorType": "%s", "errorMessage": "%s"}`
,
string
(
errorType
),
expectedMsg
)
actual
:=
GetErrorResponseWithFormattedErrorMessage
(
errorType
,
errorMessage
,
invokeID
)
assert
.
Equal
(
t
,
errorType
,
actual
.
FunctionError
.
Type
)
assert
.
Equal
(
t
,
expectedMsg
,
actual
.
FunctionError
.
Message
)
assert
.
JSONEq
(
t
,
expectedJSON
,
string
(
actual
.
Payload
))
}
func
TestDoneMetadataMetricsDimensionsStringWhenInvokeResponseModeIsPresent
(
t
*
testing.
T
) {
dimensions
:=
DoneMetadataMetricsDimensions
{
InvokeResponseMode
:
InvokeResponseModeStreaming
,
}
assert
.
Equal
(
t
,
"invoke_response_mode=streaming"
,
dimensions
.
String
())
}
func
TestDoneMetadataMetricsDimensionsStringWhenEmpty
(
t
*
testing.
T
) {
dimensions
:=
DoneMetadataMetricsDimensions
{}
assert
.
Equal
(
t
,
""
,
dimensions
.
String
())
}
Back
|
FazBrowse Home
|
New Git URL