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

Function TestCustomErrorMarshaling

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

Source from the content-addressed store, hash-verified

63}
64
65func TestCustomErrorMarshaling(t *testing.T) {
66 type CustomError struct{ error }
67 errors := []error{
68 errors.New("boring"),
69 CustomError{errors.New("Something bad happened!")},
70 messages.InvokeResponse_Error{Type: "yolo", Message: "hello"},
71 }
72 expected := []string{
73 `{ "errorType": "errorString", "errorMessage": "boring"}`,
74 `{ "errorType": "CustomError", "errorMessage": "Something bad happened!" }`,
75 `{ "errorType": "yolo", "errorMessage": "hello" }`,
76 }
77 require.Equal(t, len(errors), len(expected))
78 ts, record := runtimeAPIServer(``, len(errors))
79 defer ts.Close()
80 n := 0
81 handler := NewHandler(func() error {
82 defer func() { n++ }()
83 return errors[n]
84 })
85 endpoint := strings.Split(ts.URL, "://")[1]
86 expectedError := fmt.Sprintf("failed to GET http://%s/2018-06-01/runtime/invocation/next: got unexpected status code: 410", endpoint)
87 assert.EqualError(t, startRuntimeAPILoop(endpoint, handler), expectedError)
88 for i := range errors {
89 assert.JSONEq(t, expected[i], string(record.responses[i]))
90 assert.Equal(t, contentTypeJSON, record.contentTypes[i])
91 }
92}
93
94func TestXRayCausePlumbing(t *testing.T) {
95 errors := []error{

Callers

nothing calls this directly

Calls 4

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…