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

Function TestRuntimeAPILoop

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

Source from the content-addressed store, hash-verified

42}
43
44func 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
65func TestCustomErrorMarshaling(t *testing.T) {
66 type CustomError struct{ 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…