TestFuture just runs slow functions, and makes sure that it returns the expected result after the expected amount of time.
(t *testing.T)
| 27 | // TestFuture just runs slow functions, and makes sure that it returns the |
| 28 | // expected result after the expected amount of time. |
| 29 | func TestFuture(t *testing.T) { |
| 30 | start := time.Now() |
| 31 | |
| 32 | ctx := context.Background() |
| 33 | future := SlowFunction(ctx) |
| 34 | |
| 35 | res, err := future.Result() |
| 36 | if err != nil { |
| 37 | t.Error(err) |
| 38 | return |
| 39 | } |
| 40 | |
| 41 | if !strings.HasPrefix(res, "I slept for") { |
| 42 | t.Error("unexpected output:", res) |
| 43 | } |
| 44 | |
| 45 | elapsedCheck(t, start, 2) |
| 46 | } |
| 47 | |
| 48 | // TestFutureGetTwice tests that subsequent calls to future.Result() |
| 49 | // immediately return the initial return values. |
nothing calls this directly
no test coverage detected