main f2d166b

scenelog_test.go RawHistoryFolder

1package app
2
3import (
4	"strings"
5	"testing"
6
7	"github.com/bnema/neferwl/internal/ports"
8	"github.com/bnema/zerowrap"
9)
10
11func logTestScenes() []ports.Scene {
12	return []ports.Scene{{
13		Output: "A", Seq: 7, OutputWidth: 1920, OutputHeight: 1080, Scale: 1,
14		Windows: []ports.SceneWindow{
15			{ID: 1, Rect: ports.Rect{X: 10, Y: 20, W: 300, H: 200}},
16			{ID: 2, Rect: ports.Rect{X: 5, Y: 6, W: 7, H: 8}},
17		},
18	}, {Output: "B"}}
19}
20
21// With debug off the scene log builds nothing: no rect strings, no event.
22// Measured before the level check: 3 allocations per run for two scenes.
23func TestLogScenesAllocations(t *testing.T) {
24	out := &lockedBuffer{}
25	log := zerowrap.New(zerowrap.Config{Format: "json", Level: "info", Output: out})
26	set := logTestScenes()
27	if got := testing.AllocsPerRun(100, func() { logScenes(log, set) }); got != 0 {
28		t.Fatalf("logScenes at info level: %g allocations per run, want 0", got)
29	}
30	if out.String() != "" {
31		t.Fatalf("info level logged: %s", out.String())
32	}
33}
34
35func TestLogScenesDebug(t *testing.T) {
36	out := &lockedBuffer{}
37	log := zerowrap.New(zerowrap.Config{Format: "json", Level: "debug", Output: out})
38	logScenes(log, logTestScenes())
39	got := out.String()
40	for _, want := range []string{
41		`"output":"A"`, `"seq":7`, `"out_w":1920`, `"out_h":1080`, `"scale":1`,
42		`"windows":["1:10,20 300x200","2:5,6 7x8"]`,
43		`"message":"scene"`,
44	} {
45		if !strings.Contains(got, want) {
46			t.Fatalf("debug log lacks %s: %s", want, got)
47		}
48	}
49	if n := strings.Count(got, `"message":"scene"`); n != 2 {
50		t.Fatalf("%d scene entries, want 2: %s", n, got)
51	}
52}

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 25

Tags 10

↑↓ moveenter openesc close