package routing_test import ( "testing" "github.com/mathiasbq/supervisor/internal/routing" "github.com/stretchr/testify/assert" ) func ptr(f float64) *float64 { return &f } func TestPolicyDecide(t *testing.T) { p := routing.Policy{Floor: 0.9, Ceil: 0.7} cases := []struct { name string passRate *float64 hash uint64 want routing.Decision }{ {"null pass rate → local", nil, 0, routing.DecideLocal}, {"null pass rate, hash irrelevant → local", nil, 0xDEADBEEF, routing.DecideLocal}, {"at floor → local", ptr(0.9), 0, routing.DecideLocal}, {"above floor → local", ptr(0.95), 0, routing.DecideLocal}, {"below ceil → claude", ptr(0.5), 0, routing.DecideClaude}, {"at ceil → sample-band even-hash → local", ptr(0.7), 0, routing.DecideLocal}, {"sample band, even hash → local", ptr(0.8), 2, routing.DecideLocal}, {"sample band, odd hash → claude", ptr(0.8), 3, routing.DecideClaude}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { assert.Equal(t, tc.want, p.Decide(tc.passRate, tc.hash)) }) } }