detached 0b10c36

test(ports): restore Theme wire flag coverage

commit
0b10c36194efe0589e52af7a57c02c83998bd0ae
author
brice · · 2026-07-17 08:21 UTC
parent
5c34841
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +65 -29
M internal/ports/wire_test.go +65 -29
@@ -254,35 +254,71 @@ func TestThemeGoldenAndRoundTrip(t *testing.T) {
254254 {R: 0x34, G: 0x35, B: 0x36}, {R: 0x37, G: 0x38, B: 0x39},
255255 {R: 0x3a, G: 0x3b, B: 0x3c}, {R: 0x3d, G: 0x3e, B: 0x3f},
256256 }
257- msg := Theme{
258- HasForeground: true,
259- Foreground: renderer.RGB{R: 1, G: 2, B: 3},
260- HasBackground: true,
261- Background: renderer.RGB{R: 4, G: 5, B: 6},
262- TrueColor: true,
263- SchemeKnown: true,
264- PaletteKnown: 0x8001,
265- Palette: palette,
266- }
267- want := []byte{
268- 0x0f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x80, 0x01,
269- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
270- 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21,
271- 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
272- 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
273- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c,
274- 0x3d, 0x3e, 0x3f,
275- }
276-
277- got := MarshalTheme(msg)
278- require.Len(t, got, 57)
279- require.Equal(t, want, got)
280- back, err := UnmarshalTheme(got)
281- require.NoError(t, err)
282- require.Equal(t, msg, back)
283-
284- assertAllPrefixesFail(t, got, UnmarshalTheme)
285- assertTrailingGarbageFails(t, got, UnmarshalTheme)
257+ zeroes := make([]byte, 57)
258+ tests := []struct {
259+ name string
260+ msg Theme
261+ want []byte
262+ }{
263+ {
264+ name: "empty",
265+ msg: Theme{},
266+ want: zeroes,
267+ },
268+ {
269+ name: "foreground only",
270+ msg: Theme{
271+ HasForeground: true,
272+ Foreground: renderer.RGB{R: 10, G: 20, B: 30},
273+ Background: renderer.RGB{R: 40, G: 50, B: 60},
274+ },
275+ want: append([]byte{0x01, 0x0a, 0x14, 0x1e, 0x28, 0x32, 0x3c}, zeroes[7:]...),
276+ },
277+ {
278+ name: "light flag without known scheme",
279+ msg: Theme{
280+ Light: true,
281+ },
282+ want: append([]byte{0x10}, zeroes[1:]...),
283+ },
284+ {
285+ name: "full palette",
286+ msg: Theme{
287+ HasForeground: true,
288+ Foreground: renderer.RGB{R: 1, G: 2, B: 3},
289+ HasBackground: true,
290+ Background: renderer.RGB{R: 4, G: 5, B: 6},
291+ TrueColor: true,
292+ SchemeKnown: true,
293+ PaletteKnown: 0x8001,
294+ Palette: palette,
295+ },
296+ want: []byte{
297+ 0x0f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x80, 0x01,
298+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
299+ 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21,
300+ 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
301+ 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
302+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c,
303+ 0x3d, 0x3e, 0x3f,
304+ },
305+ },
306+ }
307+
308+ for _, tt := range tests {
309+ t.Run(tt.name, func(t *testing.T) {
310+ got := MarshalTheme(tt.msg)
311+ require.Len(t, got, 57)
312+ require.Equal(t, tt.want, got)
313+ back, err := UnmarshalTheme(got)
314+ require.NoError(t, err)
315+ require.Equal(t, tt.msg, back)
316+ })
317+ }
318+
319+ full := MarshalTheme(tests[len(tests)-1].msg)
320+ assertAllPrefixesFail(t, full, UnmarshalTheme)
321+ assertTrailingGarbageFails(t, full, UnmarshalTheme)
286322 }
287323
288324 func TestResizeGoldenAndRoundTrip(t *testing.T) {
@@ -254,35 +254,71 @@ func TestThemeGoldenAndRoundTrip(t *testing.T) {
254 {R: 0x34, G: 0x35, B: 0x36}, {R: 0x37, G: 0x38, B: 0x39},254 {R: 0x34, G: 0x35, B: 0x36}, {R: 0x37, G: 0x38, B: 0x39},
255 {R: 0x3a, G: 0x3b, B: 0x3c}, {R: 0x3d, G: 0x3e, B: 0x3f},255 {R: 0x3a, G: 0x3b, B: 0x3c}, {R: 0x3d, G: 0x3e, B: 0x3f},
256 }256 }
257- msg := Theme{257+ zeroes := make([]byte, 57)
258- HasForeground: true,258+ tests := []struct {
259- Foreground: renderer.RGB{R: 1, G: 2, B: 3},259+ name string
260- HasBackground: true,260+ msg Theme
261- Background: renderer.RGB{R: 4, G: 5, B: 6},261+ want []byte
262- TrueColor: true,262+ }{
263- SchemeKnown: true,263+ {
264- PaletteKnown: 0x8001,264+ name: "empty",
265- Palette: palette,265+ msg: Theme{},
266- }266+ want: zeroes,
267- want := []byte{267+ },
268- 0x0f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x80, 0x01,268+ {
269- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,269+ name: "foreground only",
270- 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21,270+ msg: Theme{
271- 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,271+ HasForeground: true,
272- 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,272+ Foreground: renderer.RGB{R: 10, G: 20, B: 30},
273- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c,273+ Background: renderer.RGB{R: 40, G: 50, B: 60},
274- 0x3d, 0x3e, 0x3f,274+ },
275- }275+ want: append([]byte{0x01, 0x0a, 0x14, 0x1e, 0x28, 0x32, 0x3c}, zeroes[7:]...),
276-276+ },
277- got := MarshalTheme(msg)277+ {
278- require.Len(t, got, 57)278+ name: "light flag without known scheme",
279- require.Equal(t, want, got)279+ msg: Theme{
280- back, err := UnmarshalTheme(got)280+ Light: true,
281- require.NoError(t, err)281+ },
282- require.Equal(t, msg, back)282+ want: append([]byte{0x10}, zeroes[1:]...),
283-283+ },
284- assertAllPrefixesFail(t, got, UnmarshalTheme)284+ {
285- assertTrailingGarbageFails(t, got, UnmarshalTheme)285+ name: "full palette",
286+ msg: Theme{
287+ HasForeground: true,
288+ Foreground: renderer.RGB{R: 1, G: 2, B: 3},
289+ HasBackground: true,
290+ Background: renderer.RGB{R: 4, G: 5, B: 6},
291+ TrueColor: true,
292+ SchemeKnown: true,
293+ PaletteKnown: 0x8001,
294+ Palette: palette,
295+ },
296+ want: []byte{
297+ 0x0f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x80, 0x01,
298+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
299+ 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21,
300+ 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
301+ 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
302+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c,
303+ 0x3d, 0x3e, 0x3f,
304+ },
305+ },
306+ }
307+
308+ for _, tt := range tests {
309+ t.Run(tt.name, func(t *testing.T) {
310+ got := MarshalTheme(tt.msg)
311+ require.Len(t, got, 57)
312+ require.Equal(t, tt.want, got)
313+ back, err := UnmarshalTheme(got)
314+ require.NoError(t, err)
315+ require.Equal(t, tt.msg, back)
316+ })
317+ }
318+
319+ full := MarshalTheme(tests[len(tests)-1].msg)
320+ assertAllPrefixesFail(t, full, UnmarshalTheme)
321+ assertTrailingGarbageFails(t, full, UnmarshalTheme)
286 }322 }
287 323
288 func TestResizeGoldenAndRoundTrip(t *testing.T) {324 func TestResizeGoldenAndRoundTrip(t *testing.T) {

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