MCPcopy
hub / github.com/cortexlabs/cortex / TestSemaphoreAcquireHasNoCapacity

Function TestSemaphoreAcquireHasNoCapacity

pkg/proxy/breaker_test.go:247–259  ·  view source on GitHub ↗

Test empty semaphore, token cannot be acquired

(t *testing.T)

Source from the content-addressed store, hash-verified

245
246// Test empty semaphore, token cannot be acquired
247func TestSemaphoreAcquireHasNoCapacity(t *testing.T) {
248 gotChan := make(chan struct{}, 1)
249
250 sem := newSemaphore(1, 0)
251 tryAcquire(sem, gotChan)
252
253 select {
254 case <-gotChan:
255 t.Error("Token was acquired but shouldn't have been")
256 case <-time.After(semNoChangeTimeout):
257 // Test succeeds, semaphore didn't change in configured time.
258 }
259}
260
261func TestSemaphoreAcquireNonBlockingHasNoCapacity(t *testing.T) {
262 sem := newSemaphore(1, 0)

Callers

nothing calls this directly

Calls 3

newSemaphoreFunction · 0.85
tryAcquireFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected