(t *testing.T)
| 42 | } |
| 43 | |
| 44 | func TestRuntimeAPILoop(t *testing.T) { |
| 45 | nInvokes := 10 |
| 46 | |
| 47 | ts, record := runtimeAPIServer(``, nInvokes) |
| 48 | defer ts.Close() |
| 49 | |
| 50 | n := 0 |
| 51 | handler := NewHandler(func(ctx context.Context) (string, error) { |
| 52 | n += 1 |
| 53 | if n%3 == 0 { |
| 54 | return "", errors.New("error time!") |
| 55 | } |
| 56 | return "Hello!", nil |
| 57 | }) |
| 58 | endpoint := strings.Split(ts.URL, "://")[1] |
| 59 | expectedError := fmt.Sprintf("failed to GET http://%s/2018-06-01/runtime/invocation/next: got unexpected status code: 410", endpoint) |
| 60 | assert.EqualError(t, startRuntimeAPILoop(endpoint, handler), expectedError) |
| 61 | assert.Equal(t, nInvokes+1, record.nGets) |
| 62 | assert.Equal(t, nInvokes, record.nPosts) |
| 63 | } |
| 64 | |
| 65 | func TestCustomErrorMarshaling(t *testing.T) { |
| 66 | type CustomError struct{ error } |
nothing calls this directly
no test coverage detected
searching dependent graphs…