package eval import ( "strings" "testing" "time" ) func TestSwitchStaysDirectWithoutScores(t *testing.T) { dec := DecideSwitch(nil, nil) if dec.Met || !strings.Contains(Report(dec), "保持 direct") { t.Fatalf("%+v %s", dec, Report(dec)) } } func TestSwitchRequiresScoreAndLatency(t *testing.T) { direct := &EntryScore{Name: "direct", Score: 80, FirstTokenP50: time.Second} slow := &EntryScore{Name: "squad", Score: 90, FirstTokenP50: 5 * time.Second} if DecideSwitch(direct, slow).Met { t.Fatal("extra latency above 3s must block the switch") } ok := &EntryScore{Name: "squad", Score: 80, FirstTokenP50: 3 * time.Second} dec := DecideSwitch(direct, ok) if !dec.Met || !strings.Contains(Report(dec), "改为 squad") { t.Fatalf("%+v %s", dec, Report(dec)) } }