Skip to content
quarry Artifact [701068a052]
Login

Artifact [701068a052]

Artifact 701068a0521343a4c6832e96d7d3974b9f056564ebaaed2a5684b6d774124147:


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")
	}
}