Keep stale virtual member copy when the remote lookup fails
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful

This commit is contained in:
2026-10-25 19:06:58 +11:00
parent e5313342ba
commit de80fd84c2
2 changed files with 17 additions and 2 deletions
+15
View File
@@ -328,3 +328,18 @@ func TestMergePrunesExpiredCopiesOfOtherMembers(t *testing.T) {
t.Fatal("any merge should prune expired copies of removed members")
}
}
func TestServeStaleLookupErrorKeepsCopy(t *testing.T) {
e, _ := staleEngine(true, func() *RPMMember { return rpmPkgMember("a", "1") })
v1 := fetchRepomd(t, e)
e.getRemote = func(context.Context, string) (*models.Remote, error) { return nil, errors.New("db down") }
if got := fetchRepomd(t, e); got != v1 {
t.Fatal("a failed remote lookup should keep serving the previous copy")
}
waitRefresh(e, rpmStaleKey)
e.mu.Lock()
defer e.mu.Unlock()
if e.stale[rpmStaleKey] == nil || e.stale[rpmStaleKey].m == nil {
t.Fatal("a failed remote lookup must not drop the copy")
}
}