(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestResetConcurrency(t *testing.T) { |
| 20 | t.Parallel() |
| 21 | tests := []struct { |
| 22 | name string |
| 23 | parallelism int |
| 24 | maxConcurrent int |
| 25 | numTargets int |
| 26 | expectedConcurrency int |
| 27 | expectedConcurrencyAfterTargetRemoval int |
| 28 | }{ |
| 29 | { |
| 30 | name: "Test create at least one processor per target", |
| 31 | parallelism: 0, |
| 32 | maxConcurrent: 0, |
| 33 | numTargets: 2, |
| 34 | expectedConcurrency: 2, |
| 35 | expectedConcurrencyAfterTargetRemoval: 1, |
| 36 | }, |
| 37 | { |
| 38 | name: "Test parallelism per target", |
| 39 | parallelism: 4, |
| 40 | maxConcurrent: 0, |
| 41 | numTargets: 2, |
| 42 | expectedConcurrency: 8, |
| 43 | expectedConcurrencyAfterTargetRemoval: 4, |
| 44 | }, |
| 45 | { |
| 46 | name: "Test Total Parallelism with a remainder", |
| 47 | parallelism: 1, |
| 48 | maxConcurrent: 7, |
| 49 | numTargets: 4, |
| 50 | expectedConcurrency: 7, |
| 51 | expectedConcurrencyAfterTargetRemoval: 7, |
| 52 | }, |
| 53 | { |
| 54 | name: "Test Total Parallelism dividing evenly", |
| 55 | parallelism: 1, |
| 56 | maxConcurrent: 6, |
| 57 | numTargets: 2, |
| 58 | expectedConcurrency: 6, |
| 59 | expectedConcurrencyAfterTargetRemoval: 6, |
| 60 | }, |
| 61 | { |
| 62 | name: "Test Total Parallelism at least one worker per target", |
| 63 | parallelism: 1, |
| 64 | maxConcurrent: 3, |
| 65 | numTargets: 6, |
| 66 | expectedConcurrency: 6, |
| 67 | expectedConcurrencyAfterTargetRemoval: 5, |
| 68 | }, |
| 69 | } |
| 70 | |
| 71 | for _, tt := range tests { |
| 72 | t.Run(tt.name, func(t *testing.T) { |
| 73 | t.Parallel() |
| 74 | cfg := Config{ |
| 75 | Parallelism: tt.parallelism, |
| 76 | MatchMaxConcurrency: tt.maxConcurrent > 0, |
nothing calls this directly
no test coverage detected