25 lines
609 B
Go
25 lines
609 B
Go
package loadsim
|
|
|
|
import "testing"
|
|
|
|
func TestConnectionBatchesSpreadsConnectionsByRate(t *testing.T) {
|
|
got := ConnectionBatches(2500, 1000)
|
|
want := []int{1000, 1000, 500}
|
|
|
|
if len(got) != len(want) {
|
|
t.Fatalf("len = %d, want %d: %#v", len(got), len(want), got)
|
|
}
|
|
for i := range want {
|
|
if got[i] != want[i] {
|
|
t.Fatalf("batch[%d] = %d, want %d: %#v", i, got[i], want[i], got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestConnectionBatchesUsesOneBatchWhenTargetBelowRate(t *testing.T) {
|
|
got := ConnectionBatches(300, 1000)
|
|
if len(got) != 1 || got[0] != 300 {
|
|
t.Fatalf("ConnectionBatches() = %#v, want []int{300}", got)
|
|
}
|
|
}
|