Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
23 lines
575 B
Go
23 lines
575 B
Go
package mirror
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestAFinishedDownloadIsForgottenAfterAWeek(t *testing.T) {
|
|
m := NewManager(t.TempDir(), discardLog())
|
|
now := time.Now()
|
|
m.mu.Lock()
|
|
m.running["old"] = &Status{State: Present, FinishedAt: now.Add(-keptFinished - time.Hour)}
|
|
m.running["recent"] = &Status{State: Failed, FinishedAt: now.Add(-time.Hour)}
|
|
m.running["going"] = &Status{State: Fetching}
|
|
m.forgetOld(now)
|
|
_, old := m.running["old"]
|
|
n := len(m.running)
|
|
m.mu.Unlock()
|
|
if old || n != 2 {
|
|
t.Errorf("after a week: old remembered=%v, %d left", old, n)
|
|
}
|
|
}
|