Test empty semaphore, token cannot be acquired
(t *testing.T)
| 245 | |
| 246 | // Test empty semaphore, token cannot be acquired |
| 247 | func 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 | |
| 261 | func TestSemaphoreAcquireNonBlockingHasNoCapacity(t *testing.T) { |
| 262 | sem := newSemaphore(1, 0) |
nothing calls this directly
no test coverage detected