Chunk the uploads when reuploading to avoid having one giant request

This commit is contained in:
David Dworken
2022-10-10 22:04:59 -07:00
parent 8e6a55237c
commit 9da18eb7d5
2 changed files with 41 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import (
"os"
"os/user"
"path"
"reflect"
"strings"
"testing"
"time"
@ -283,3 +284,22 @@ func TestMaybeSkipBashHistTimePrefix(t *testing.T) {
}
}
}
func TestChunks(t *testing.T) {
testcases := []struct {
input []int
chunkSize int
output [][]int
}{
{[]int{1, 2, 3, 4, 5}, 2, [][]int{{1, 2}, {3, 4}, {5}}},
{[]int{1, 2, 3, 4, 5}, 3, [][]int{{1, 2, 3}, {4, 5}}},
{[]int{1, 2, 3, 4, 5}, 1, [][]int{{1}, {2}, {3}, {4}, {5}}},
{[]int{1, 2, 3, 4, 5}, 4, [][]int{{1, 2, 3, 4}, {5}}},
}
for _, tc := range testcases {
actual := chunks(tc.input, tc.chunkSize)
if !reflect.DeepEqual(actual, tc.output) {
t.Fatal("chunks failure")
}
}
}