MCPcopy Index your code
hub / github.com/foxcpp/maddy / TestFuture_Wait

Function TestFuture_Wait

framework/future/future_test.go:42–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestFuture_Wait(t *testing.T) {
43 f := New()
44
45 go func() {
46 time.Sleep(500 * time.Millisecond)
47 f.Set(1, errors.New("1"))
48 }()
49
50 val, err := f.Get()
51 if val, _ := val.(int); val != 1 {
52 t.Fatal("wrong val received from Get")
53 }
54 if err.Error() != "1" {
55 t.Error("Wrong error:", err)
56 }
57
58 val, err = f.Get()
59 if val, _ := val.(int); val != 1 {
60 t.Fatal("wrong val received from Get on second try")
61 }
62 if err.Error() != "1" {
63 t.Error("Wrong error:", err)
64 }
65}
66
67func TestFuture_WaitCtx(t *testing.T) {
68 f := New()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.70
SetMethod · 0.45
GetMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected