mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Utils: Add chunks_test.go
This commit is contained in:
parent
887bbd59df
commit
aa6e9b43bc
1 changed files with 51 additions and 0 deletions
51
utils/chunks_test.go
Normal file
51
utils/chunks_test.go
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"github.com/magiconair/properties/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestChunkKeys(t *testing.T) {
|
||||
keys := []string{
|
||||
"herp",
|
||||
"derp",
|
||||
"merp",
|
||||
"berp",
|
||||
}
|
||||
|
||||
ch := ChunkKeys(make(chan struct{}), keys, 2)
|
||||
var chunks [][]string
|
||||
for chunk := range ch {
|
||||
chunks = append(chunks, chunk)
|
||||
}
|
||||
|
||||
want := [][]string{
|
||||
{
|
||||
"herp",
|
||||
"derp",
|
||||
},
|
||||
{
|
||||
"merp",
|
||||
"berp",
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, chunks, want)
|
||||
|
||||
ch = ChunkKeys(make(chan struct{}), keys, 5)
|
||||
chunks = nil
|
||||
for chunk := range ch {
|
||||
chunks = append(chunks, chunk)
|
||||
}
|
||||
|
||||
want = [][]string{
|
||||
{
|
||||
"herp",
|
||||
"derp",
|
||||
"merp",
|
||||
"berp",
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, chunks, want)
|
||||
}
|
||||
Loading…
Reference in a new issue