Files
felhom.eu/hub/internal/offsitekeys/r1255_setaside_name_test.go
T
admin 1ee6d5a507
gates / gates (push) Successful in 1m52s
hub: R-1255 escrow edges (HUNT-3 H3/H4) — the carry takes the package with a hash; set-aside names unique per run; the purge never takes a reused path's package
Tests red before the fix: TestR1255_TheCarryTakesTheNewestPackageThatHasAHash,
TestR1255_APurgeNeverDeletesAPackageAReusedPathStillNeeds, TestR1255_TwoSetAsidesOnOneDayGetTwoNames.
Commit only; rides the next hub release.
2026-10-28 22:40:01 +01:00

36 lines
1.3 KiB
Go

package offsitekeys
import (
"context"
"testing"
"time"
)
// R-1255 H4: a set-aside name is unique per run. The name was `<repo>.orphaned-<date>`: a copy set aside, abandoned
// and deleted the same day freed the name, and the next set-aside took it again — two copies, one name, and the
// packages tagged with it could no longer be told apart (the purge took both). The stamp now carries the time.
// RED-PROOF: go back to Format("20060102") in Service.MoveAside → both runs give the same name → FAILS.
func TestR1255_TwoSetAsidesOnOneDayGetTwoNames(t *testing.T) {
s, fs, _ := svcFixture(t)
clock := time.Date(2026, 10, 28, 9, 0, 0, 0, time.UTC)
s.Now = func() time.Time { return clock }
fs.dirs["/home/felhom-repo"] = true
first, err := s.MoveAside(context.Background(), "c1")
if err != nil {
t.Fatal(err)
}
delete(fs.dirs, first) // abandoned and deleted the same day
fs.dirs["/home/felhom-repo"] = true
clock = clock.Add(3 * time.Hour)
second, err := s.MoveAside(context.Background(), "c1")
if err != nil {
t.Fatal(err)
}
if first == second {
t.Fatalf("two set-asides on one day share the name %q", first)
}
if !IsSetAsidePath("/home/felhom-repo", first) || !IsSetAsidePath("/home/felhom-repo", second) {
t.Fatalf("names %q / %q are not set-aside paths", first, second)
}
}