MCPcopy Index your code
hub / github.com/aws/aws-lambda-go / TestContextPlumbing

Function TestContextPlumbing

lambda/rpc_function_test.go:128–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

126}
127
128func TestContextPlumbing(t *testing.T) {
129 srv := NewFunction(testWrapperHandler(
130 func(ctx context.Context, input []byte) (interface{}, error) {
131 lc, _ := lambdacontext.FromContext(ctx)
132 return lc, nil
133 },
134 ))
135 var response messages.InvokeResponse
136 err := srv.Invoke(&messages.InvokeRequest{
137 CognitoIdentityId: "dummyident",
138 CognitoIdentityPoolId: "dummypool",
139 ClientContext: []byte(`{
140 "Client": {
141 "app_title": "dummytitle",
142 "installation_id": "dummyinstallid",
143 "app_version_code": "dummycode",
144 "app_package_name": "dummyname"
145 }
146 }`),
147 RequestId: "dummyid",
148 InvokedFunctionArn: "dummyarn",
149 }, &response)
150 assert.NoError(t, err)
151 assert.NotNil(t, response.Payload)
152 expected := `
153 {
154 "AwsRequestID": "dummyid",
155 "InvokedFunctionArn": "dummyarn",
156 "Identity": {
157 "CognitoIdentityID": "dummyident",
158 "CognitoIdentityPoolID": "dummypool"
159 },
160 "ClientContext": {
161 "Client": {
162 "installation_id": "dummyinstallid",
163 "app_title": "dummytitle",
164 "app_version_code": "dummycode",
165 "app_package_name": "dummyname"
166 },
167 "env": null,
168 "custom": null
169 }
170 }
171 `
172 assert.JSONEq(t, expected, string(response.Payload))
173}
174
175func TestXAmznTraceID(t *testing.T) {
176 type XRayResponse struct {

Callers

nothing calls this directly

Calls 4

InvokeMethod · 0.95
FromContextFunction · 0.92
NewFunctionFunction · 0.85
testWrapperHandlerFuncType · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…