MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestLimiter_TryAck

Function TestLimiter_TryAck

internal/utils/fs/limiter_test.go:52–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestLimiter_TryAck(t *testing.T) {
53 var a = assert.NewAssertion(t)
54
55 {
56 var limiter = fsutils.NewLimiter(4)
57 var count = limiter.FreeThreads()
58 a.IsTrue(count == 4)
59 for i := 0; i < count; i++ {
60 limiter.Ack()
61 }
62 a.IsTrue(limiter.FreeThreads() == 0)
63 a.IsFalse(limiter.TryAck())
64 a.IsTrue(limiter.FreeThreads() == 0)
65 }
66
67 {
68 var limiter = fsutils.NewLimiter(4)
69 var count = limiter.FreeThreads()
70 a.IsTrue(count == 4)
71 for i := 0; i < count-1; i++ {
72 limiter.Ack()
73 }
74 a.IsTrue(limiter.FreeThreads() == 1)
75 a.IsTrue(limiter.TryAck())
76 a.IsTrue(limiter.FreeThreads() == 0)
77 }
78}
79
80func TestLimiter_TryAck2(t *testing.T) {
81 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 3

FreeThreadsMethod · 0.80
TryAckMethod · 0.80
AckMethod · 0.45

Tested by

no test coverage detected