MCPcopy
hub / github.com/syncthing/syncthing / TestByteSemaphoreCapChangeUp

Function TestByteSemaphoreCapChangeUp

lib/semaphore/semaphore_test.go:24–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22}
23
24func TestByteSemaphoreCapChangeUp(t *testing.T) {
25 t.Parallel()
26
27 // Waiting takes should unblock when the capacity increases
28
29 s := New(100)
30
31 s.Take(75)
32 if s.available != 25 {
33 t.Error("bad state after take")
34 }
35
36 gotit := make(chan struct{})
37 go func() {
38 s.Take(75)
39 close(gotit)
40 }()
41
42 s.SetCapacity(155)
43 <-gotit
44 if s.available != 5 {
45 t.Error("bad state after both takes")
46 }
47}
48
49func TestByteSemaphoreCapChangeDown1(t *testing.T) {
50 t.Parallel()

Callers

nothing calls this directly

Calls 4

SetCapacityMethod · 0.80
NewFunction · 0.70
ErrorMethod · 0.65
TakeMethod · 0.45

Tested by

no test coverage detected