Files
masyunis/internal/bundler/bundler_test.go
T
sol_bot Bot e07de898cd Import Anubis v1.28.2
Replace the tree with upstream TecharoHQ/anubis v1.28.2 (a1384fbf42e3).
Masyunis customizations are re-applied in the following commits.
2026-11-28 14:52:26 +03:00

40 lines
620 B
Go

package bundler
import (
"context"
"testing"
)
func TestBundler(t *testing.T) {
input := []int{1, 2, 3, 4}
done := false
b := New[int](func(_ context.Context, data []int) {
if len(data) != 4 {
t.Errorf("Wanted len(data) == %d, got: %d", len(input), len(data))
}
sum := 0
const wantSum = 10
for _, i := range data {
sum += i
}
if sum != wantSum {
t.Errorf("wanted sum of inputs to be %d, got: %d", wantSum, sum)
}
done = true
})
for _, i := range input {
if err := b.Add(i, 1); err != nil {
t.Fatal(err)
}
}
b.Flush()
if !done {
t.Fatal("function wasn't called")
}
}