(t *testing.T)
| 63 | } |
| 64 | |
| 65 | func 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 | |
| 94 | func TestXRayCausePlumbing(t *testing.T) { |
| 95 | errors := []error{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…