MCPcopy Create free account
hub / github.com/cloud-native-go/examples / TestTimeoutYes

Function TestTimeoutYes

ch04/timeout_test.go:36–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func TestTimeoutYes(t *testing.T) {
37 ctx, cancel := context.WithTimeout(context.Background(), time.Second/2)
38 defer cancel()
39
40 timeout := Timeout(Slow)
41 _, err := timeout(ctx, "some input")
42 if err == nil {
43 t.Fatal("Didn't get expected timeout error")
44 }
45}
46
47func Slow(s string) (string, error) {
48 time.Sleep(time.Second)

Callers

nothing calls this directly

Calls 1

TimeoutFunction · 0.85

Tested by

no test coverage detected