(t *testing.T)
| 390 | } |
| 391 | |
| 392 | func 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 | |
| 432 | type invalidPayload struct{} |
| 433 |
nothing calls this directly
no test coverage detected
searching dependent graphs…