33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package assignment
|
|
|
|
import "testing"
|
|
|
|
// The per-miler concurrent-stop cap.
|
|
//
|
|
// This is the knob that now decides how much one rider carries, because
|
|
// eligibility no longer stops at the first order. It is read per call so it
|
|
// can be changed without a redeploy — and a typo must never uncap the fleet.
|
|
func TestMaxActiveBookings(t *testing.T) {
|
|
cases := []struct {
|
|
env string
|
|
want int64
|
|
why string
|
|
}{
|
|
{"", defaultMaxActive, "unset falls back to the default"},
|
|
{"10", 10, "a plain number is honoured"},
|
|
{" 8 ", 8, "surrounding whitespace is tolerated"},
|
|
{"1", 1, "one stop at a time is a legitimate policy"},
|
|
{"0", defaultMaxActive, "zero would assign to nobody — treated as unset, not as a cap"},
|
|
{"-4", defaultMaxActive, "negative is meaningless here"},
|
|
{"lots", defaultMaxActive, "a typo must not uncap the fleet"},
|
|
{"3.5", defaultMaxActive, "not an integer"},
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
t.Setenv("MILER_MAX_ACTIVE_BOOKINGS", tc.env)
|
|
if got := maxActiveBookings(); got != tc.want {
|
|
t.Errorf("MILER_MAX_ACTIVE_BOOKINGS=%q gave %d, want %d (%s)", tc.env, got, tc.want, tc.why)
|
|
}
|
|
}
|
|
}
|