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

Function TestXAmznTraceID

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

Source from the content-addressed store, hash-verified

173}
174
175func TestXAmznTraceID(t *testing.T) {
176 type XRayResponse struct {
177 Env string
178 Ctx string
179 }
180
181 srv := NewFunction(testWrapperHandler(
182 func(ctx context.Context, input []byte) (interface{}, error) {
183 return &XRayResponse{
184 Env: os.Getenv("_X_AMZN_TRACE_ID"),
185 Ctx: ctx.Value("x-amzn-trace-id").(string),
186 }, nil
187 },
188 ))
189
190 sequence := []struct {
191 Input string
192 Expected string
193 }{
194 {
195 "",
196 `{"Env": "", "Ctx": ""}`,
197 },
198 {
199 "dummyid",
200 `{"Env": "dummyid", "Ctx": "dummyid"}`,
201 },
202 {
203 "",
204 `{"Env": "", "Ctx": ""}`,
205 },
206 {
207 "123dummyid",
208 `{"Env": "123dummyid", "Ctx": "123dummyid"}`,
209 },
210 {
211 "",
212 `{"Env": "", "Ctx": ""}`,
213 },
214 {
215 "",
216 `{"Env": "", "Ctx": ""}`,
217 },
218 {
219 "567",
220 `{"Env": "567", "Ctx": "567"}`,
221 },
222 {
223 "hihihi",
224 `{"Env": "hihihi", "Ctx": "hihihi"}`,
225 },
226 }
227
228 for i, test := range sequence {
229 var response messages.InvokeResponse
230 err := srv.Invoke(&messages.InvokeRequest{XAmznTraceId: test.Input}, &response)
231 require.NoError(t, err, "failed test sequence[%d]", i)
232 assert.JSONEq(t, test.Expected, string(response.Payload), "failed test sequence[%d]", i)

Callers

nothing calls this directly

Calls 4

InvokeMethod · 0.95
NewFunctionFunction · 0.85
testWrapperHandlerFuncType · 0.85
ValueMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…