detached aeec46d

test(recover): rename snapshot entry helper to avoid clash with tree entry

commit
aeec46d3b4465e629f731b56575c4c827630e1a0
author
brice · · 2026-10-10 01:59 UTC
parent
ecf0370
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +9 -9
M recover_test.go +9 -9
@@ -93,7 +93,7 @@ func snapshotBytes(t *testing.T, seq uint64, entries ...snapEntry) []byte {
9393 return encodeSnapshot(t, seq, entries)
9494 }
9595
96-func entry(k, v string, ver uint64) snapEntry { return snapEntry{[]byte(k), []byte(v), ver} }
96+func snapEnt(k, v string, ver uint64) snapEntry { return snapEntry{[]byte(k), []byte(v), ver} }
9797
9898 func wantState(t *testing.T, s *state, m map[string]string) {
9999 t.Helper()
@@ -373,11 +373,11 @@ func TestRecoverSeqGap(t *testing.T) {
373373 put(fx, logName(4), logBytes(4, []op{putOp("a", "1")}))
374374 },
375375 "log after snapshot has a gap": func(fx *faultfs.FS) {
376- put(fx, snapshotName(3), snapshotBytes(t, 3, entry("a", "1", 3)))
376+ put(fx, snapshotName(3), snapshotBytes(t, 3, snapEnt("a", "1", 3)))
377377 put(fx, logName(5), logBytes(5, []op{putOp("b", "2")}))
378378 },
379379 "logs end before snapshot": func(fx *faultfs.FS) {
380- put(fx, snapshotName(5), snapshotBytes(t, 5, entry("a", "1", 3)))
380+ put(fx, snapshotName(5), snapshotBytes(t, 5, snapEnt("a", "1", 3)))
381381 put(fx, logName(0), logBytes(0, []op{putOp("a", "1")}))
382382 },
383383 "duplicate seq": func(fx *faultfs.FS) {
@@ -400,7 +400,7 @@ func TestRecoverSeqGap(t *testing.T) {
400400
401401 func TestRecoverSnapshotThenLogs(t *testing.T) {
402402 fx := faultfs.New()
403- put(fx, snapshotName(3), snapshotBytes(t, 3, entry("a", "1", 1), entry("b", "2", 3)))
403+ put(fx, snapshotName(3), snapshotBytes(t, 3, snapEnt("a", "1", 1), snapEnt("b", "2", 3)))
404404 // log-0 still holds records already in the snapshot; log-3 continues it.
405405 put(fx, logName(0), logBytes(0, []op{putOp("a", "old")}, []op{putOp("x", "gone")}, []op{putOp("b", "2")}))
406406 put(fx, logName(3), logBytes(3, []op{putOp("c", "3")}, []op{delOp("a")}))
@@ -419,7 +419,7 @@ func TestRecoverSnapshotThenLogs(t *testing.T) {
419419
420420 func TestRecoverSnapshotWithoutLogCreatesLog(t *testing.T) {
421421 fx := faultfs.New()
422- put(fx, snapshotName(7), snapshotBytes(t, 7, entry("a", "1", 7)))
422+ put(fx, snapshotName(7), snapshotBytes(t, 7, snapEnt("a", "1", 7)))
423423 s, rec := mustRecover(t, fx)
424424 wantState(t, s, map[string]string{"a": "1"})
425425 if rec.snapSeq != 7 || rec.lastSeq != 7 || rec.logBase != 7 || rec.logSize != logHeaderSize {
@@ -431,12 +431,12 @@ func TestRecoverSnapshotWithoutLogCreatesLog(t *testing.T) {
431431 }
432432
433433 func TestRecoverInvalidNewestSnapshotFallsBack(t *testing.T) {
434- good := snapshotBytes(t, 2, entry("a", "1", 1), entry("b", "2", 2))
435- newer := snapshotBytes(t, 4, entry("a", "1", 1), entry("z", "9", 4))
434+ good := snapshotBytes(t, 2, snapEnt("a", "1", 1), snapEnt("b", "2", 2))
435+ newer := snapshotBytes(t, 4, snapEnt("a", "1", 1), snapEnt("z", "9", 4))
436436 truncated := newer[:len(newer)-2]
437437 flipped := append([]byte(nil), newer...)
438438 flipped[30] ^= 1
439- wrongName := snapshotBytes(t, 3, entry("a", "1", 1))
439+ wrongName := snapshotBytes(t, 3, snapEnt("a", "1", 1))
440440 for name, bad := range map[string][]byte{"truncated": truncated, "flipped": flipped, "empty": nil, "seq/name mismatch": wrongName} {
441441 t.Run(name, func(t *testing.T) {
442442 fx := faultfs.New()
@@ -486,7 +486,7 @@ func TestRecoverNoSnapshotStartsAtZero(t *testing.T) {
486486
487487 func TestRecoverSnapshotLoadOrderAndOwnership(t *testing.T) {
488488 fx := faultfs.New()
489- put(fx, snapshotName(1), snapshotBytes(t, 1, entry("a", "1", 1), entry("b", "2", 1), entry("c", "3", 1)))
489+ put(fx, snapshotName(1), snapshotBytes(t, 1, snapEnt("a", "1", 1), snapEnt("b", "2", 1), snapEnt("c", "3", 1)))
490490 var keys []string
491491 var held [][]byte
492492 _, err := recoverDir(fx, testDir, nil, func(k, v []byte, ver uint64) {
@@ -93,7 +93,7 @@ func snapshotBytes(t *testing.T, seq uint64, entries ...snapEntry) []byte {
93 return encodeSnapshot(t, seq, entries)93 return encodeSnapshot(t, seq, entries)
94 }94 }
95 95
96-func entry(k, v string, ver uint64) snapEntry { return snapEntry{[]byte(k), []byte(v), ver} }96+func snapEnt(k, v string, ver uint64) snapEntry { return snapEntry{[]byte(k), []byte(v), ver} }
97 97
98 func wantState(t *testing.T, s *state, m map[string]string) {98 func wantState(t *testing.T, s *state, m map[string]string) {
99 t.Helper()99 t.Helper()
@@ -373,11 +373,11 @@ func TestRecoverSeqGap(t *testing.T) {
373 put(fx, logName(4), logBytes(4, []op{putOp("a", "1")}))373 put(fx, logName(4), logBytes(4, []op{putOp("a", "1")}))
374 },374 },
375 "log after snapshot has a gap": func(fx *faultfs.FS) {375 "log after snapshot has a gap": func(fx *faultfs.FS) {
376- put(fx, snapshotName(3), snapshotBytes(t, 3, entry("a", "1", 3)))376+ put(fx, snapshotName(3), snapshotBytes(t, 3, snapEnt("a", "1", 3)))
377 put(fx, logName(5), logBytes(5, []op{putOp("b", "2")}))377 put(fx, logName(5), logBytes(5, []op{putOp("b", "2")}))
378 },378 },
379 "logs end before snapshot": func(fx *faultfs.FS) {379 "logs end before snapshot": func(fx *faultfs.FS) {
380- put(fx, snapshotName(5), snapshotBytes(t, 5, entry("a", "1", 3)))380+ put(fx, snapshotName(5), snapshotBytes(t, 5, snapEnt("a", "1", 3)))
381 put(fx, logName(0), logBytes(0, []op{putOp("a", "1")}))381 put(fx, logName(0), logBytes(0, []op{putOp("a", "1")}))
382 },382 },
383 "duplicate seq": func(fx *faultfs.FS) {383 "duplicate seq": func(fx *faultfs.FS) {
@@ -400,7 +400,7 @@ func TestRecoverSeqGap(t *testing.T) {
400 400
401 func TestRecoverSnapshotThenLogs(t *testing.T) {401 func TestRecoverSnapshotThenLogs(t *testing.T) {
402 fx := faultfs.New()402 fx := faultfs.New()
403- put(fx, snapshotName(3), snapshotBytes(t, 3, entry("a", "1", 1), entry("b", "2", 3)))403+ put(fx, snapshotName(3), snapshotBytes(t, 3, snapEnt("a", "1", 1), snapEnt("b", "2", 3)))
404 // log-0 still holds records already in the snapshot; log-3 continues it.404 // log-0 still holds records already in the snapshot; log-3 continues it.
405 put(fx, logName(0), logBytes(0, []op{putOp("a", "old")}, []op{putOp("x", "gone")}, []op{putOp("b", "2")}))405 put(fx, logName(0), logBytes(0, []op{putOp("a", "old")}, []op{putOp("x", "gone")}, []op{putOp("b", "2")}))
406 put(fx, logName(3), logBytes(3, []op{putOp("c", "3")}, []op{delOp("a")}))406 put(fx, logName(3), logBytes(3, []op{putOp("c", "3")}, []op{delOp("a")}))
@@ -419,7 +419,7 @@ func TestRecoverSnapshotThenLogs(t *testing.T) {
419 419
420 func TestRecoverSnapshotWithoutLogCreatesLog(t *testing.T) {420 func TestRecoverSnapshotWithoutLogCreatesLog(t *testing.T) {
421 fx := faultfs.New()421 fx := faultfs.New()
422- put(fx, snapshotName(7), snapshotBytes(t, 7, entry("a", "1", 7)))422+ put(fx, snapshotName(7), snapshotBytes(t, 7, snapEnt("a", "1", 7)))
423 s, rec := mustRecover(t, fx)423 s, rec := mustRecover(t, fx)
424 wantState(t, s, map[string]string{"a": "1"})424 wantState(t, s, map[string]string{"a": "1"})
425 if rec.snapSeq != 7 || rec.lastSeq != 7 || rec.logBase != 7 || rec.logSize != logHeaderSize {425 if rec.snapSeq != 7 || rec.lastSeq != 7 || rec.logBase != 7 || rec.logSize != logHeaderSize {
@@ -431,12 +431,12 @@ func TestRecoverSnapshotWithoutLogCreatesLog(t *testing.T) {
431 }431 }
432 432
433 func TestRecoverInvalidNewestSnapshotFallsBack(t *testing.T) {433 func TestRecoverInvalidNewestSnapshotFallsBack(t *testing.T) {
434- good := snapshotBytes(t, 2, entry("a", "1", 1), entry("b", "2", 2))434+ good := snapshotBytes(t, 2, snapEnt("a", "1", 1), snapEnt("b", "2", 2))
435- newer := snapshotBytes(t, 4, entry("a", "1", 1), entry("z", "9", 4))435+ newer := snapshotBytes(t, 4, snapEnt("a", "1", 1), snapEnt("z", "9", 4))
436 truncated := newer[:len(newer)-2]436 truncated := newer[:len(newer)-2]
437 flipped := append([]byte(nil), newer...)437 flipped := append([]byte(nil), newer...)
438 flipped[30] ^= 1438 flipped[30] ^= 1
439- wrongName := snapshotBytes(t, 3, entry("a", "1", 1))439+ wrongName := snapshotBytes(t, 3, snapEnt("a", "1", 1))
440 for name, bad := range map[string][]byte{"truncated": truncated, "flipped": flipped, "empty": nil, "seq/name mismatch": wrongName} {440 for name, bad := range map[string][]byte{"truncated": truncated, "flipped": flipped, "empty": nil, "seq/name mismatch": wrongName} {
441 t.Run(name, func(t *testing.T) {441 t.Run(name, func(t *testing.T) {
442 fx := faultfs.New()442 fx := faultfs.New()
@@ -486,7 +486,7 @@ func TestRecoverNoSnapshotStartsAtZero(t *testing.T) {
486 486
487 func TestRecoverSnapshotLoadOrderAndOwnership(t *testing.T) {487 func TestRecoverSnapshotLoadOrderAndOwnership(t *testing.T) {
488 fx := faultfs.New()488 fx := faultfs.New()
489- put(fx, snapshotName(1), snapshotBytes(t, 1, entry("a", "1", 1), entry("b", "2", 1), entry("c", "3", 1)))489+ put(fx, snapshotName(1), snapshotBytes(t, 1, snapEnt("a", "1", 1), snapEnt("b", "2", 1), snapEnt("c", "3", 1)))
490 var keys []string490 var keys []string
491 var held [][]byte491 var held [][]byte
492 _, err := recoverDir(fx, testDir, nil, func(k, v []byte, ver uint64) {492 _, err := recoverDir(fx, testDir, nil, func(k, v []byte, ver uint64) {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 2

↑↓ moveenter openesc close