(t *testing.T)
| 15 | type ctxTestKey struct{} |
| 16 | |
| 17 | func TestStartRuntimeAPIWithContext(t *testing.T) { |
| 18 | server, _ := runtimeAPIServer("null", 1) // serve a single invoke, and then cause an internal error |
| 19 | expected := "expected" |
| 20 | actual := "unexpected" |
| 21 | |
| 22 | os.Setenv("AWS_LAMBDA_RUNTIME_API", strings.Split(server.URL, "://")[1]) |
| 23 | defer os.Unsetenv("AWS_LAMBDA_RUNTIME_API") |
| 24 | logFatalf = func(format string, v ...interface{}) {} |
| 25 | defer func() { logFatalf = log.Fatalf }() |
| 26 | |
| 27 | StartWithContext(context.WithValue(context.Background(), ctxTestKey{}, expected), func(ctx context.Context) error { |
| 28 | actual, _ = ctx.Value(ctxTestKey{}).(string) |
| 29 | return nil |
| 30 | }) |
| 31 | |
| 32 | assert.Equal(t, expected, actual) |
| 33 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…