(t *testing.T)
| 39 | } |
| 40 | |
| 41 | func TestBlockingGate(t *testing.T) { |
| 42 | t.Run("not at concurrency limit", func(t *testing.T) { |
| 43 | ctx, cancel := context.WithCancel(context.Background()) |
| 44 | defer cancel() |
| 45 | |
| 46 | g := NewBlocking(1) |
| 47 | err1 := g.Start(ctx) |
| 48 | require.NoError(t, err1) |
| 49 | |
| 50 | g.Done() |
| 51 | err2 := g.Start(ctx) |
| 52 | require.NoError(t, err2) |
| 53 | }) |
| 54 | |
| 55 | t.Run("at concurrency limit", func(t *testing.T) { |
| 56 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond) |
| 57 | defer cancel() |
| 58 | |
| 59 | g := NewBlocking(1) |
| 60 | err1 := g.Start(ctx) |
| 61 | err2 := g.Start(ctx) |
| 62 | |
| 63 | require.NoError(t, err1) |
| 64 | require.ErrorIs(t, err2, context.DeadlineExceeded) |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | func TestInstrumentedGate(t *testing.T) { |
| 69 | t.Run("max concurrency", func(t *testing.T) { |
nothing calls this directly
no test coverage detected