cache: include nar_url in ListRecentRoutes; test expired TTL in GetRouteByNarURL
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I952d08726f34d0d9b7c4c1880d60222c6a6a6964
This commit is contained in:
parent
2ae611b916
commit
ded9b6d464
2 changed files with 20 additions and 2 deletions
18
internal/cache/db_test.go
vendored
18
internal/cache/db_test.go
vendored
|
|
@ -276,6 +276,24 @@ func TestGetRouteByNarURL(t *testing.T) {
|
|||
if got2 != nil {
|
||||
t.Error("expected nil for missing NarURL")
|
||||
}
|
||||
|
||||
// Expired entry must not be returned (tests the AND ttl > ? predicate).
|
||||
expired := &cache.RouteEntry{
|
||||
StorePath: "abc456",
|
||||
UpstreamURL: "https://cache.nixos.org",
|
||||
NarURL: "nar/abc456.nar.xz",
|
||||
TTL: time.Now().Add(-time.Hour), // already in the past
|
||||
}
|
||||
if err := db.SetRoute(expired); err != nil {
|
||||
t.Fatalf("SetRoute expired: %v", err)
|
||||
}
|
||||
got3, err := db.GetRouteByNarURL("nar/abc456.nar.xz")
|
||||
if err != nil {
|
||||
t.Fatalf("GetRouteByNarURL for expired: %v", err)
|
||||
}
|
||||
if got3 != nil {
|
||||
t.Error("GetRouteByNarURL should return nil for an expired entry")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLRUEviction(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue