MCPcopy Create free account
hub / github.com/Shopify/goose / TestStateTracker_Wait

Function TestStateTracker_Wait

statetracker/tracker_test.go:31–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func TestStateTracker_Wait(t *testing.T) {
32 tracker := New(false)
33
34 waiting := make(chan struct{}, 1)
35 ready := make(chan struct{}, 1)
36 go func() {
37 waiting <- struct{}{}
38 assert.True(t, tracker.Wait(context.Background(), true))
39 ready <- struct{}{}
40 }()
41
42 assert.True(t, len(ready) == 0, "should not yet be ready")
43
44 tracker.Set(false)
45 assert.True(t, len(ready) == 0, "should not yet be ready")
46
47 select {
48 case <-time.After(100 * time.Millisecond):
49 assert.Fail(t, "should be waiting by now")
50 case <-waiting:
51 }
52 tracker.Set(true)
53
54 select {
55 case <-time.After(100 * time.Millisecond):
56 assert.Fail(t, "should be ready by now")
57 case <-ready:
58 }
59}
60
61func TestStateTracker_Listener(t *testing.T) {
62 var runCount uint32

Callers

nothing calls this directly

Calls 3

NewFunction · 0.70
WaitMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected