(t *testing.T)
| 64 | } |
| 65 | |
| 66 | func TestInvokeWithContext(t *testing.T) { |
| 67 | key := struct{}{} |
| 68 | srv := NewFunction(&handlerOptions{ |
| 69 | handlerFunc: func(ctx context.Context, _ []byte) (io.Reader, error) { |
| 70 | assert.Equal(t, "dummy", ctx.Value(key)) |
| 71 | if deadline, ok := ctx.Deadline(); ok { |
| 72 | return strings.NewReader(strconv.FormatInt(deadline.UnixNano(), 10)), nil |
| 73 | } |
| 74 | return nil, errors.New("!?!?!?!?!") |
| 75 | }, |
| 76 | baseContext: context.WithValue(context.Background(), key, "dummy"), |
| 77 | }) |
| 78 | deadline := time.Now() |
| 79 | var response messages.InvokeResponse |
| 80 | err := srv.Invoke(&messages.InvokeRequest{ |
| 81 | Deadline: messages.InvokeRequest_Timestamp{ |
| 82 | Seconds: deadline.Unix(), |
| 83 | Nanos: int64(deadline.Nanosecond()), |
| 84 | }}, &response) |
| 85 | assert.NoError(t, err) |
| 86 | var responseValue int64 |
| 87 | assert.NoError(t, json.Unmarshal(response.Payload, &responseValue)) |
| 88 | assert.Equal(t, deadline.UnixNano(), responseValue) |
| 89 | } |
| 90 | |
| 91 | type CustomError struct{} |
| 92 |
nothing calls this directly
no test coverage detected
searching dependent graphs…