package zitcli
import (
"context"
"testing"
)
// The maintenance lane waits while store calls are crowding the gate:
// more than half the slots in use is pressure, half or fewer is not.
func TestAdmissionPressureIsMoreThanHalfInUse(t *testing.T) {
a := newAdmission(4)
for i, want := range []bool{false, false, false, true, true} {
if got := a.pressured(); got != want {
t.Errorf("FAIL: with %d of 4 slots held pressured=%v, want %v", i, got, want)
}
if i < 4 {
a.acquire(context.Background())
}
}
a.release()
a.release()
if a.pressured() {
t.Errorf("FAIL: released slots still read as pressure")
}
if !t.Failed() {
t.Log("ok")
}
}