MCPcopy
hub / github.com/destel/rill / TestBatch

Function TestBatch

batch_test.go:10–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestBatch(t *testing.T) {
11 // most logic is covered by the chans pkg tests
12
13 t.Run("correctness", func(t *testing.T) {
14 in := FromChan(th.FromRange(0, 10), fmt.Errorf("err0"))
15 in = replaceWithError(in, 5, fmt.Errorf("err5"))
16 in = replaceWithError(in, 7, fmt.Errorf("err7"))
17
18 batches, errs := toSliceAndErrors(Batch(in, 3, -1))
19
20 th.ExpectValue(t, len(batches), 3)
21 th.ExpectSlice(t, batches[0], []int{0, 1, 2})
22 th.ExpectSlice(t, batches[1], []int{3, 4, 6})
23 th.ExpectSlice(t, batches[2], []int{8, 9})
24
25 th.ExpectSlice(t, errs, []string{"err0", "err5", "err7"})
26 })
27
28}
29
30func TestUnbatch(t *testing.T) {
31 // most logic is covered by the common package tests

Callers

nothing calls this directly

Calls 7

FromRangeFunction · 0.92
ExpectValueFunction · 0.92
ExpectSliceFunction · 0.92
FromChanFunction · 0.85
replaceWithErrorFunction · 0.85
toSliceAndErrorsFunction · 0.85
BatchFunction · 0.70

Tested by

no test coverage detected