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

Function TestStartRuntimeAPIWithContext

lambda/entry_test.go:17–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15type ctxTestKey struct{}
16
17func 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}

Callers

nothing calls this directly

Calls 3

runtimeAPIServerFunction · 0.85
StartWithContextFunction · 0.85
ValueMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…