proxy-pool/internal/domain/activitypool/upstream_lookup_test.go
youfak 65aee12d51
Some checks are pending
ci / proto (push) Waiting to run
ci / test (ubuntu-latest) (push) Waiting to run
ci / test (windows-latest) (push) Waiting to run
ci / race (push) Waiting to run
ci / integration (push) Waiting to run
feat: wire checker observations into controller
2026-07-31 18:25:07 +08:00

24 lines
846 B
Go

package activitypool
import (
"context"
"errors"
"testing"
"time"
)
func TestMemoryPoolLooksUpOnlyLiveProxyUpstream(t *testing.T) {
now := time.Date(2026, 7, 31, 15, 0, 0, 0, time.UTC)
pool := seededHealthPool(t, now)
upstream, err := pool.UpstreamForProxy(context.Background(), "proxy-a", now.Add(time.Second))
if err != nil || upstream != "provider-a" {
t.Fatalf("UpstreamForProxy(live) = (%q, %v)", upstream, err)
}
if _, err := pool.UpstreamForProxy(context.Background(), "proxy-a", now.Add(2*time.Minute)); !errors.Is(err, ErrActivityNotFound) {
t.Fatalf("UpstreamForProxy(expired) error = %v, want ErrActivityNotFound", err)
}
if _, err := pool.UpstreamForProxy(context.Background(), "", now); !errors.Is(err, ErrInvalidProxyLookup) {
t.Fatalf("UpstreamForProxy(empty) error = %v, want ErrInvalidProxyLookup", err)
}
}