(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestCompletionTracker(t *testing.T) { |
| 10 | const addShards = -1 |
| 11 | |
| 12 | tcs := []struct { |
| 13 | name string |
| 14 | add []int // -1 means send shards |
| 15 | shards []Shard |
| 16 | exp []uint32 // expected completedThroughSeconds after each operation |
| 17 | }{ |
| 18 | // shards only |
| 19 | { |
| 20 | name: "shards only", |
| 21 | add: []int{addShards}, |
| 22 | shards: []Shard{ |
| 23 | { |
| 24 | TotalJobs: 1, |
| 25 | CompletedThroughSeconds: 100, |
| 26 | }, |
| 27 | }, |
| 28 | exp: []uint32{0}, |
| 29 | }, |
| 30 | // indexes only |
| 31 | { |
| 32 | name: "indexes only", |
| 33 | add: []int{1, 0, 1, 3, 2, 0, 1, 1}, |
| 34 | shards: []Shard{ |
| 35 | { |
| 36 | TotalJobs: 1, |
| 37 | CompletedThroughSeconds: 100, |
| 38 | }, |
| 39 | }, |
| 40 | exp: []uint32{0, 0, 0, 0, 0, 0, 0, 0}, |
| 41 | }, |
| 42 | // first shard complete, shards first |
| 43 | { |
| 44 | name: "first shard complete, shards first", |
| 45 | add: []int{addShards, 0}, |
| 46 | shards: []Shard{ |
| 47 | { |
| 48 | TotalJobs: 1, |
| 49 | CompletedThroughSeconds: 100, |
| 50 | }, |
| 51 | }, |
| 52 | exp: []uint32{0, 1}, // 1 = TimestampAlways when all shards complete |
| 53 | }, |
| 54 | // first shard complete, index first |
| 55 | { |
| 56 | name: "first shard complete, index first", |
| 57 | add: []int{0, addShards}, |
| 58 | shards: []Shard{ |
| 59 | { |
| 60 | TotalJobs: 1, |
| 61 | CompletedThroughSeconds: 100, |
| 62 | }, |
| 63 | }, |
| 64 | exp: []uint32{0, 1}, // 1 = TimestampAlways when all shards complete |
| 65 | }, |
| 66 | // shards received at various times |
nothing calls this directly
no test coverage detected