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

Function TestInvoke

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

Source from the content-addressed store, hash-verified

42var _ Handler = (testWrapperHandler)(nil)
43
44func TestInvoke(t *testing.T) {
45 srv := NewFunction(testWrapperHandler(
46 func(ctx context.Context, input []byte) (interface{}, error) {
47 if deadline, ok := ctx.Deadline(); ok {
48 return deadline.UnixNano(), nil
49 }
50 return nil, errors.New("!?!?!?!?!")
51 },
52 ))
53 deadline := time.Now()
54 var response messages.InvokeResponse
55 err := srv.Invoke(&messages.InvokeRequest{
56 Deadline: messages.InvokeRequest_Timestamp{
57 Seconds: deadline.Unix(),
58 Nanos: int64(deadline.Nanosecond()),
59 }}, &response)
60 assert.NoError(t, err)
61 var responseValue int64
62 assert.NoError(t, json.Unmarshal(response.Payload, &responseValue))
63 assert.Equal(t, deadline.UnixNano(), responseValue)
64}
65
66func TestInvokeWithContext(t *testing.T) {
67 key := struct{}{}

Callers

nothing calls this directly

Calls 4

InvokeMethod · 0.95
NewFunctionFunction · 0.85
testWrapperHandlerFuncType · 0.85
DeadlineMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…