MCPcopy
hub / github.com/gotify/server / Test_Execute

Function Test_Execute

api/stream/once_test.go:10–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func Test_Execute(t *testing.T) {
11 executeOnce := once{}
12 execution := make(chan struct{})
13 fExecute := func() {
14 execution <- struct{}{}
15 }
16 go executeOnce.Do(fExecute)
17 go executeOnce.Do(fExecute)
18
19 select {
20 case <-execution:
21 // expected
22 case <-time.After(100 * time.Millisecond):
23 t.Fatal("fExecute should be executed once")
24 }
25
26 select {
27 case <-execution:
28 t.Fatal("should only execute once")
29 case <-time.After(100 * time.Millisecond):
30 // expected
31 }
32
33 assert.False(t, executeOnce.mayExecute())
34
35 go executeOnce.Do(fExecute)
36
37 select {
38 case <-execution:
39 t.Fatal("should only execute once")
40 case <-time.After(100 * time.Millisecond):
41 // expected
42 }
43}

Callers

nothing calls this directly

Calls 2

DoMethod · 0.95
mayExecuteMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…