(t *testing.T)
| 34 | } |
| 35 | |
| 36 | func 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 | |
| 47 | func Slow(s string) (string, error) { |
| 48 | time.Sleep(time.Second) |