(t *testing.T)
| 39 | ) |
| 40 | |
| 41 | func TestBreakerInvalidConstructor(t *testing.T) { |
| 42 | tests := []struct { |
| 43 | name string |
| 44 | options BreakerParams |
| 45 | }{{ |
| 46 | name: "QueueDepth = 0", |
| 47 | options: BreakerParams{QueueDepth: 0, MaxConcurrency: 1, InitialCapacity: 1}, |
| 48 | }, { |
| 49 | name: "MaxConcurrency negative", |
| 50 | options: BreakerParams{QueueDepth: 1, MaxConcurrency: -1, InitialCapacity: 1}, |
| 51 | }, { |
| 52 | name: "InitialCapacity negative", |
| 53 | options: BreakerParams{QueueDepth: 1, MaxConcurrency: 1, InitialCapacity: -1}, |
| 54 | }, { |
| 55 | name: "InitialCapacity out-of-bounds", |
| 56 | options: BreakerParams{QueueDepth: 1, MaxConcurrency: 5, InitialCapacity: 6}, |
| 57 | }} |
| 58 | |
| 59 | for _, test := range tests { |
| 60 | t.Run(test.name, func(t *testing.T) { |
| 61 | defer func() { |
| 62 | if r := recover(); r == nil { |
| 63 | t.Error("Expected a panic but the code didn't panic.") |
| 64 | } |
| 65 | }() |
| 66 | |
| 67 | NewBreaker(test.options) |
| 68 | }) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | func TestBreakerReserveOverload(t *testing.T) { |
| 73 | params := BreakerParams{QueueDepth: 1, MaxConcurrency: 1, InitialCapacity: 1} |
nothing calls this directly
no test coverage detected