The Providers page built agent.All for Detected beside the one accountLabel looks names up in (provider.Held), and the state built it twice (Clients, Detected). They now share the request's held list (heldAgents; agent.DetectedIn, agent.ClientsIn), as /api/drift does. notProbed gathered every vendor and local preset's bases for each provider of each poll; it now asks a set made once (presetHosts). Run on mote (darwin): go vet and go test of internal/agent, internal/gui and internal/provider: agent and gui ok; provider red only in TestMoveToPlugin's TempDir cleanup (#5524, passes alone). TestNotProbedSetMatchesThePresets: broken by hand (set rebuilt per ask) it measured 44 allocations an ask, red; 0 restored.
35 lines
1014 B
Go
35 lines
1014 B
Go
package provider
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestNotProbedSetMatchesThePresets: notProbed answers from a set made
|
|
// once of the vendors' and local servers' preset hosts, as the walk over
|
|
// every preset it replaced did, and with no garbage per ask.
|
|
func TestNotProbedSetMatchesThePresets(t *testing.T) {
|
|
for _, d := range presets {
|
|
bases := []string{d.Chat, d.Responses, d.Anthropic}
|
|
for _, r := range d.Regions {
|
|
bases = append(bases, r.Chat, r.Responses, r.Anthropic)
|
|
}
|
|
for _, b := range bases {
|
|
h := hostnameOf(b)
|
|
if b == "" || h == "" {
|
|
continue
|
|
}
|
|
want := d.Kind == KindVendor || d.Kind == KindLocal
|
|
if want && !notProbed(strings.ToUpper(h)) {
|
|
t.Errorf("%s (%s): %s is probed, want left alone", d.ID, d.Kind, h)
|
|
}
|
|
}
|
|
}
|
|
if notProbed("relay.example.com") {
|
|
t.Error("a relay's host is not probed")
|
|
}
|
|
if got := testing.AllocsPerRun(100, func() { notProbed("api.deepseek.com") }); got > 0 {
|
|
t.Errorf("notProbed allocates %v times an ask, want 0", got)
|
|
}
|
|
}
|