| 1 | package runner |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestAcquireSlotStopsAtConcurrency(t *testing.T) { |
| 6 | r := &Runner{slots: make(chan struct{}, 1)} |
| 7 | if !r.acquireSlot() { |
| 8 | t.Fatal("eerste slot") |
| 9 | } |
| 10 | if r.acquireSlot() { |
| 11 | t.Fatal("tweede slot hoort vol te zijn") |
| 12 | } |
| 13 | r.releaseSlot() |
| 14 | if !r.acquireSlot() { |
| 15 | t.Fatal("na vrijgeven") |
| 16 | } |
| 17 | open := &Runner{} |
| 18 | if !open.acquireSlot() { |
| 19 | t.Fatal("zonder limiet") |
| 20 | } |
| 21 | open.releaseSlot() |
| 22 | } |