(t *testing.T)
| 353 | } |
| 354 | |
| 355 | func TestContextDeserializationErrors(t *testing.T) { |
| 356 | badClientContext := defaultInvokeMetadata() |
| 357 | badClientContext.clientContext = `{ not json }` |
| 358 | |
| 359 | badCognito := defaultInvokeMetadata() |
| 360 | badCognito.cognito = `{ not json }` |
| 361 | |
| 362 | badDeadline := defaultInvokeMetadata() |
| 363 | badDeadline.deadline = `yolo` |
| 364 | |
| 365 | badMetadata := []eventMetadata{badClientContext, badCognito, badDeadline} |
| 366 | |
| 367 | ts, record := runtimeAPIServer(`{}`, len(badMetadata), badMetadata...) |
| 368 | defer ts.Close() |
| 369 | handler := NewHandler(func(ctx context.Context) (*lambdacontext.LambdaContext, error) { |
| 370 | lc, _ := lambdacontext.FromContext(ctx) |
| 371 | return lc, nil |
| 372 | }) |
| 373 | endpoint := strings.Split(ts.URL, "://")[1] |
| 374 | _ = startRuntimeAPILoop(endpoint, handler) |
| 375 | |
| 376 | assert.JSONEq(t, `{ |
| 377 | "errorMessage":"failed to unmarshal client context json: invalid character 'n' looking for beginning of object key string", |
| 378 | "errorType":"errorString" |
| 379 | }`, string(record.responses[0])) |
| 380 | |
| 381 | assert.JSONEq(t, `{ |
| 382 | "errorMessage":"failed to unmarshal cognito identity json: invalid character 'n' looking for beginning of object key string", |
| 383 | "errorType":"errorString" |
| 384 | }`, string(record.responses[1])) |
| 385 | |
| 386 | assert.JSONEq(t, `{ |
| 387 | "errorMessage":"failed to parse deadline: strconv.ParseInt: parsing \"yolo\": invalid syntax", |
| 388 | "errorType":"errorString" |
| 389 | }`, string(record.responses[2])) |
| 390 | } |
| 391 | |
| 392 | func TestClientContextWithNestedCustomValues(t *testing.T) { |
| 393 | metadata := defaultInvokeMetadata() |
nothing calls this directly
no test coverage detected
searching dependent graphs…