detached 2c3eaa1

test(vt): cover partial history chunk capacity

commit
2c3eaa1deadfcabd5149cda391974ff504528299
author
brice · · 2026-07-12 15:07 UTC
parent
adf2142
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +26 -10
M pkg/vt/history_test.go +26 -10
@@ -8,30 +8,46 @@ import (
88
99 func TestHistoryOrdersSealedChunksAndEvictsAtCapacity(t *testing.T) {
1010 tests := []struct {
11- name string
12- rows []string
13- want []string
11+ name string
12+ maxRows int
13+ chunkRows int
14+ rows []string
15+ want []string
1416 }{
1517 {
16- name: "oldest chunks are evicted before newer chunks",
17- rows: []string{"aaaa", "bbbb", "cccc", "dddd", "eeee", "ffff"},
18- want: []string{"cccc", "dddd", "eeee", "ffff"},
18+ name: "oldest chunks are evicted before newer chunks",
19+ maxRows: 4,
20+ chunkRows: 2,
21+ rows: []string{"aaaa", "bbbb", "cccc", "dddd", "eeee", "ffff"},
22+ want: []string{"cccc", "dddd", "eeee", "ffff"},
23+ },
24+ {
25+ name: "nonmultiple capacity evicts a whole oldest immutable chunk",
26+ maxRows: 5,
27+ chunkRows: 2,
28+ rows: []string{"0000", "1111", "2222", "3333", "4444", "5555"},
29+ want: []string{"2222", "3333", "4444", "5555"},
1930 },
2031 {
21- name: "rows preserve append order across chunk boundaries",
22- rows: []string{"0000", "1111", "2222", "3333"},
23- want: []string{"0000", "1111", "2222", "3333"},
32+ name: "rows preserve append order across chunk boundaries",
33+ maxRows: 4,
34+ chunkRows: 2,
35+ rows: []string{"0000", "1111", "2222", "3333"},
36+ want: []string{"0000", "1111", "2222", "3333"},
2437 },
2538 }
2639
2740 for _, tt := range tests {
2841 t.Run(tt.name, func(t *testing.T) {
29- history := NewHistory(HistoryConfig{MaxRows: 4, ChunkRows: 2})
42+ history := NewHistory(HistoryConfig{MaxRows: tt.maxRows, ChunkRows: tt.chunkRows})
3043 for _, text := range tt.rows {
3144 history.Append(historyRow(text))
3245 }
3346
3447 view := history.View()
48+ if got := view.Len(); got > tt.maxRows {
49+ t.Fatalf("retained row count = %d, exceeds capacity %d", got, tt.maxRows)
50+ }
3551 if got := historyViewTexts(view); !equalStrings(got, tt.want) {
3652 t.Fatalf("view rows = %#v, want %#v", got, tt.want)
3753 }
@@ -8,30 +8,46 @@ import (
8 8
9 func TestHistoryOrdersSealedChunksAndEvictsAtCapacity(t *testing.T) {9 func TestHistoryOrdersSealedChunksAndEvictsAtCapacity(t *testing.T) {
10 tests := []struct {10 tests := []struct {
11- name string11+ name string
12- rows []string12+ maxRows int
13- want []string13+ chunkRows int
14+ rows []string
15+ want []string
14 }{16 }{
15 {17 {
16- name: "oldest chunks are evicted before newer chunks",18+ name: "oldest chunks are evicted before newer chunks",
17- rows: []string{"aaaa", "bbbb", "cccc", "dddd", "eeee", "ffff"},19+ maxRows: 4,
18- want: []string{"cccc", "dddd", "eeee", "ffff"},20+ chunkRows: 2,
21+ rows: []string{"aaaa", "bbbb", "cccc", "dddd", "eeee", "ffff"},
22+ want: []string{"cccc", "dddd", "eeee", "ffff"},
23+ },
24+ {
25+ name: "nonmultiple capacity evicts a whole oldest immutable chunk",
26+ maxRows: 5,
27+ chunkRows: 2,
28+ rows: []string{"0000", "1111", "2222", "3333", "4444", "5555"},
29+ want: []string{"2222", "3333", "4444", "5555"},
19 },30 },
20 {31 {
21- name: "rows preserve append order across chunk boundaries",32+ name: "rows preserve append order across chunk boundaries",
22- rows: []string{"0000", "1111", "2222", "3333"},33+ maxRows: 4,
23- want: []string{"0000", "1111", "2222", "3333"},34+ chunkRows: 2,
35+ rows: []string{"0000", "1111", "2222", "3333"},
36+ want: []string{"0000", "1111", "2222", "3333"},
24 },37 },
25 }38 }
26 39
27 for _, tt := range tests {40 for _, tt := range tests {
28 t.Run(tt.name, func(t *testing.T) {41 t.Run(tt.name, func(t *testing.T) {
29- history := NewHistory(HistoryConfig{MaxRows: 4, ChunkRows: 2})42+ history := NewHistory(HistoryConfig{MaxRows: tt.maxRows, ChunkRows: tt.chunkRows})
30 for _, text := range tt.rows {43 for _, text := range tt.rows {
31 history.Append(historyRow(text))44 history.Append(historyRow(text))
32 }45 }
33 46
34 view := history.View()47 view := history.View()
48+ if got := view.Len(); got > tt.maxRows {
49+ t.Fatalf("retained row count = %d, exceeds capacity %d", got, tt.maxRows)
50+ }
35 if got := historyViewTexts(view); !equalStrings(got, tt.want) {51 if got := historyViewTexts(view); !equalStrings(got, tt.want) {
36 t.Fatalf("view rows = %#v, want %#v", got, tt.want)52 t.Fatalf("view rows = %#v, want %#v", got, tt.want)
37 }53 }

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 12

Tags 11

↑↓ moveenter openesc close