(t *testing.T)
| 153 | } |
| 154 | |
| 155 | func TestBreakerInflight(t *testing.T) { |
| 156 | params := BreakerParams{QueueDepth: 2, MaxConcurrency: 1, InitialCapacity: 1} |
| 157 | b := NewBreaker(params) // Breaker capacity = 2 |
| 158 | reqs := newRequestor(b) |
| 159 | |
| 160 | // Bring breaker to capacity. Doesn't error because queue subsumes these requests. |
| 161 | reqs.request() |
| 162 | reqs.request() |
| 163 | reqs.request() |
| 164 | |
| 165 | require.Eventually(t, func() bool { |
| 166 | return b.InFlight() == int64(3) |
| 167 | }, time.Second, 10*time.Millisecond) |
| 168 | require.Equal(t, reqs.InProgress.Load(), int64(1)) |
| 169 | } |
| 170 | |
| 171 | func TestBreakerNoOverload(t *testing.T) { |
| 172 | params := BreakerParams{QueueDepth: 1, MaxConcurrency: 1, InitialCapacity: 1} |
nothing calls this directly
no test coverage detected