1
0
Fork 0

Minor changes

This commit is contained in:
Ludovic Fernandez 2018-07-03 10:02:03 +02:00 committed by Traefiker Bot
parent bb14ec70bd
commit 17ad5153b8
38 changed files with 93 additions and 182 deletions

View file

@ -496,87 +496,6 @@ func TestFilterInstance(t *testing.T) {
}
}
func TestChunkedTaskArns(t *testing.T) {
testVal := "a"
testCases := []struct {
desc string
count int
expectedLengths []int
}{
{
desc: "0 parameter should return nil",
count: 0,
expectedLengths: []int(nil),
},
{
desc: "1 parameter should return 1 array of 1 element",
count: 1,
expectedLengths: []int{1},
},
{
desc: "99 parameters should return 1 array of 99 elements",
count: 99,
expectedLengths: []int{99},
},
{
desc: "100 parameters should return 1 array of 100 elements",
count: 100,
expectedLengths: []int{100},
},
{
desc: "101 parameters should return 1 array of 100 elements and 1 array of 1 element",
count: 101,
expectedLengths: []int{100, 1},
},
{
desc: "199 parameters should return 1 array of 100 elements and 1 array of 99 elements",
count: 199,
expectedLengths: []int{100, 99},
},
{
desc: "200 parameters should return 2 arrays of 100 elements each",
count: 200,
expectedLengths: []int{100, 100},
},
{
desc: "201 parameters should return 2 arrays of 100 elements each and 1 array of 1 element",
count: 201,
expectedLengths: []int{100, 100, 1},
},
{
desc: "555 parameters should return 5 arrays of 100 elements each and 1 array of 55 elements",
count: 555,
expectedLengths: []int{100, 100, 100, 100, 100, 55},
},
{
desc: "1001 parameters should return 10 arrays of 100 elements each and 1 array of 1 element",
count: 1001,
expectedLengths: []int{100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 1},
},
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
var tasks []*string
for v := 0; v < test.count; v++ {
tasks = append(tasks, &testVal)
}
out := chunkedTaskArns(tasks)
var outCount []int
for _, el := range out {
outCount = append(outCount, len(el))
}
assert.Equal(t, test.expectedLengths, outCount, "Chunking %d elements", test.count)
})
}
}
func TestGetHost(t *testing.T) {
testCases := []struct {
desc string