MCPcopy
hub / github.com/kubernetes/client-go / TestNeverFake

Function TestNeverFake

util/flowcontrol/throttle_test.go:127–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func TestNeverFake(t *testing.T) {
128 rl := NewFakeNeverRateLimiter()
129 if rl.TryAccept() {
130 t.Error("TryAccept in NeverFake should return false.")
131 }
132
133 finished := false
134 wg := sync.WaitGroup{}
135 wg.Add(1)
136 go func() {
137 rl.Accept()
138 finished = true
139 wg.Done()
140 }()
141
142 // Wait some time to make sure it never finished.
143 time.Sleep(time.Second)
144 if finished {
145 t.Error("Accept should block forever in NeverFake.")
146 }
147
148 rl.Stop()
149 wg.Wait()
150 if !finished {
151 t.Error("Stop should make Accept unblock in NeverFake.")
152 }
153}

Callers

nothing calls this directly

Calls 8

NewFakeNeverRateLimiterFunction · 0.85
TryAcceptMethod · 0.65
ErrorMethod · 0.65
AddMethod · 0.65
AcceptMethod · 0.65
DoneMethod · 0.65
SleepMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected