(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestBreakerReserveOverload(t *testing.T) { |
| 73 | params := BreakerParams{QueueDepth: 1, MaxConcurrency: 1, InitialCapacity: 1} |
| 74 | b := NewBreaker(params) // Breaker capacity = 2 |
| 75 | cb1, rr := b.Reserve(context.Background()) |
| 76 | if !rr { |
| 77 | t.Fatal("Reserve1 failed") |
| 78 | } |
| 79 | _, rr = b.Reserve(context.Background()) |
| 80 | if rr { |
| 81 | t.Fatal("Reserve2 was an unexpected success.") |
| 82 | } |
| 83 | // Release a slot. |
| 84 | cb1() |
| 85 | // And reserve it again. |
| 86 | cb2, rr := b.Reserve(context.Background()) |
| 87 | if !rr { |
| 88 | t.Fatal("Reserve2 failed") |
| 89 | } |
| 90 | cb2() |
| 91 | } |
| 92 | |
| 93 | func TestBreakerOverloadMixed(t *testing.T) { |
| 94 | // This tests when reservation and maybe are intermised. |
nothing calls this directly
no test coverage detected