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

Function TestClientContextWithNestedCustomValues

lambda/invoke_loop_test.go:392–430  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

390}
391
392func TestClientContextWithNestedCustomValues(t *testing.T) {
393 metadata := defaultInvokeMetadata()
394 metadata.clientContext = `{
395 "Client": {
396 "app_title": "test",
397 "installation_id": "install1",
398 "app_version_code": "1.0",
399 "app_package_name": "com.test"
400 },
401 "custom": {
402 "bedrockAgentCoreTargetId": "target-123",
403 "bedrockAgentCorePropagatedHeaders": {"x-id": "my-custom-id"}
404 }
405 }`
406
407 ts, record := runtimeAPIServer(`{}`, 1, metadata)
408 defer ts.Close()
409 handler := NewHandler(func(ctx context.Context) (interface{}, error) {
410 lc, _ := lambdacontext.FromContext(ctx)
411 return lc.ClientContext, nil
412 })
413 endpoint := strings.Split(ts.URL, "://")[1]
414 _ = startRuntimeAPILoop(endpoint, handler)
415
416 expected := `{
417 "Client": {
418 "installation_id": "install1",
419 "app_title": "test",
420 "app_version_code": "1.0",
421 "app_package_name": "com.test"
422 },
423 "env": null,
424 "custom": {
425 "bedrockAgentCoreTargetId": "target-123",
426 "bedrockAgentCorePropagatedHeaders": "{\"x-id\": \"my-custom-id\"}"
427 }
428 }`
429 assert.JSONEq(t, expected, string(record.responses[0]))
430}
431
432type invalidPayload struct{}
433

Callers

nothing calls this directly

Calls 6

FromContextFunction · 0.92
defaultInvokeMetadataFunction · 0.85
runtimeAPIServerFunction · 0.85
NewHandlerFunction · 0.85
startRuntimeAPILoopFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…