2015-07-09 15:20:12 +00:00
|
|
|
package lfs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2015-07-09 21:09:41 +00:00
|
|
|
"github.com/github/git-lfs/vendor/_nuts/github.com/technoweenie/assert"
|
2015-07-09 15:20:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestBatcherSizeMet(t *testing.T) {
|
|
|
|
b := NewBatcher(2)
|
|
|
|
|
|
|
|
for i := 0; i < 4; i++ {
|
|
|
|
b.Add(&Downloadable{})
|
|
|
|
}
|
|
|
|
|
|
|
|
group := b.Next()
|
|
|
|
assert.Equal(t, 2, len(group))
|
|
|
|
|
|
|
|
group = b.Next()
|
|
|
|
assert.Equal(t, 2, len(group))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBatcherExit(t *testing.T) {
|
|
|
|
b := NewBatcher(4)
|
|
|
|
|
|
|
|
for i := 0; i < 2; i++ {
|
|
|
|
b.Add(&Downloadable{})
|
|
|
|
}
|
|
|
|
|
|
|
|
b.Exit()
|
|
|
|
|
|
|
|
group := b.Next()
|
|
|
|
assert.Equal(t, 2, len(group))
|
|
|
|
}
|