server: update tests to use proper AddUpstream API

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I7df7f617a791c204ad7e755dac8529e16a6a6964
This commit is contained in:
raf 2026-04-05 15:12:20 +03:00
commit 81ccde99d9
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 6 additions and 0 deletions

View file

@ -37,6 +37,7 @@ func TestRouteReuseOnSecondRequest(t *testing.T) {
defer db.Close()
p := prober.New(0.3)
p.AddUpstream(upstream.URL, 0)
p.RecordLatency(upstream.URL, 10)
r := router.New(db, p, time.Hour, 5*time.Second, 10*time.Minute)
ts := httptest.NewServer(server.New(r, p, db, []config.UpstreamConfig{{URL: upstream.URL}}, 30))
@ -75,6 +76,8 @@ func TestUpstreamFailoverFallback(t *testing.T) {
defer db.Close()
p := prober.New(0.3)
p.AddUpstream(bad.URL, 0)
p.AddUpstream(good.URL, 0)
p.RecordLatency(bad.URL, 1) // bad appears fastest
p.RecordLatency(good.URL, 50)

View file

@ -33,6 +33,7 @@ func makeTestServer(t *testing.T, upstreams ...string) *httptest.Server {
p := prober.New(0.3)
for _, u := range upstreams {
p.AddUpstream(u, 0)
p.RecordLatency(u, 10)
}
@ -363,6 +364,8 @@ func TestNARFallbackWhenFirstUpstreamMissing(t *testing.T) {
p := prober.New(0.3)
// missing appears faster
p.AddUpstream(missing.URL, 0)
p.AddUpstream(hasIt.URL, 0)
p.RecordLatency(missing.URL, 1)
p.RecordLatency(hasIt.URL, 50)