(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestStream(t *testing.T) { |
| 15 | t.Parallel() |
| 16 | forEncodings(t, func(t *testing.T, enc encoding.Encoding) { |
| 17 | for i, tc := range []struct { |
| 18 | input1, input2 []promchunk.Batch |
| 19 | output batchStream |
| 20 | }{ |
| 21 | { |
| 22 | input1: []promchunk.Batch{mkBatch(0, enc)}, |
| 23 | output: []promchunk.Batch{mkBatch(0, enc)}, |
| 24 | }, |
| 25 | |
| 26 | { |
| 27 | input1: []promchunk.Batch{mkBatch(0, enc)}, |
| 28 | input2: []promchunk.Batch{mkBatch(0, enc)}, |
| 29 | output: []promchunk.Batch{mkBatch(0, enc)}, |
| 30 | }, |
| 31 | |
| 32 | { |
| 33 | input1: []promchunk.Batch{mkBatch(0, enc)}, |
| 34 | input2: []promchunk.Batch{mkBatch(promchunk.BatchSize, enc)}, |
| 35 | output: []promchunk.Batch{mkBatch(0, enc), mkBatch(promchunk.BatchSize, enc)}, |
| 36 | }, |
| 37 | |
| 38 | { |
| 39 | input1: []promchunk.Batch{mkBatch(0, enc), mkBatch(promchunk.BatchSize, enc)}, |
| 40 | input2: []promchunk.Batch{mkBatch(promchunk.BatchSize/2, enc), mkBatch(2*promchunk.BatchSize, enc)}, |
| 41 | output: []promchunk.Batch{mkBatch(0, enc), mkBatch(promchunk.BatchSize, enc), mkBatch(2*promchunk.BatchSize, enc)}, |
| 42 | }, |
| 43 | |
| 44 | { |
| 45 | input1: []promchunk.Batch{mkBatch(promchunk.BatchSize/2, enc), mkBatch(3*promchunk.BatchSize/2, enc), mkBatch(5*promchunk.BatchSize/2, enc)}, |
| 46 | input2: []promchunk.Batch{mkBatch(0, enc), mkBatch(promchunk.BatchSize, enc), mkBatch(3*promchunk.BatchSize, enc)}, |
| 47 | output: []promchunk.Batch{mkBatch(0, enc), mkBatch(promchunk.BatchSize, enc), mkBatch(2*promchunk.BatchSize, enc), mkBatch(3*promchunk.BatchSize, enc)}, |
| 48 | }, |
| 49 | } { |
| 50 | t.Run(strconv.Itoa(i), func(t *testing.T) { |
| 51 | t.Parallel() |
| 52 | result := make(batchStream, len(tc.input1)+len(tc.input2)) |
| 53 | result = mergeStreams(tc.input1, tc.input2, result, promchunk.BatchSize) |
| 54 | require.Equal(t, tc.output, result) |
| 55 | }) |
| 56 | } |
| 57 | }) |
| 58 | } |
| 59 | |
| 60 | func mkBatch(from int64, enc encoding.Encoding) promchunk.Batch { |
| 61 | var result promchunk.Batch |
nothing calls this directly
no test coverage detected