mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-09 15:15:08 +02:00
Chunk the uploads when reuploading to avoid having one giant request
This commit is contained in:
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user