v0.2.0 4c97002

parser_test.go RawHistoryFolder

1package parser
2
3import (
4	"strings"
5	"testing"
6)
7
8func TestLoadParsesLibraryAndSymbolGroups(t *testing.T) {
9	model, err := Load("testdata/minimal_pipewire.json")
10	if err != nil {
11		t.Fatalf("Load returned error: %v", err)
12	}
13	if got, want := len(model.Libraries), 1; got != want {
14		t.Fatalf("libraries=%d want %d", got, want)
15	}
16	if got, want := model.Groups[0].Name, "init"; got != want {
17		t.Fatalf("group=%q want %q", got, want)
18	}
19}
20
21func TestLoadMissingFileReturnsError(t *testing.T) {
22	_, err := Load("testdata/nonexistent_file.json")
23	if err == nil {
24		t.Fatal("expected error for missing file, got nil")
25	}
26	if !strings.Contains(err.Error(), "failed to read file") {
27		t.Fatalf("error message should contain 'failed to read file', got: %v", err)
28	}
29}
30
31func TestLoadInvalidJSONReturnsError(t *testing.T) {
32	_, err := Load("testdata/invalid.json")
33	if err == nil {
34		t.Fatal("expected error for invalid JSON, got nil")
35	}
36	if !strings.Contains(err.Error(), "failed to unmarshal JSON") {
37		t.Fatalf("error message should contain 'failed to unmarshal JSON', got: %v", err)
38	}
39}
40
41func TestLoadSymbolWithUnknownLibraryReturnsError(t *testing.T) {
42	_, err := Load("testdata/unknown_library.json")
43	if err == nil {
44		t.Fatal("expected error for symbol with unknown library, got nil")
45	}
46	if !strings.Contains(err.Error(), "unknown library") {
47		t.Fatalf("error message should contain 'unknown library', got: %v", err)
48	}
49}
50
51func TestLoadEmptyLibraryNameReturnsError(t *testing.T) {
52	_, err := Load("testdata/empty_lib_name.json")
53	if err == nil {
54		t.Fatal("expected error for empty library name, got nil")
55	}
56	if !strings.Contains(err.Error(), "validation failed") {
57		t.Fatalf("error message should contain 'validation failed', got: %v", err)
58	}
59	if !strings.Contains(err.Error(), "empty name") {
60		t.Fatalf("error message should contain 'empty name', got: %v", err)
61	}
62}
63
64func TestLoadEmptyLibrarySONameReturnsError(t *testing.T) {
65	_, err := Load("testdata/empty_lib_soname.json")
66	if err == nil {
67		t.Fatal("expected error for empty library soname, got nil")
68	}
69	if !strings.Contains(err.Error(), "validation failed") {
70		t.Fatalf("error message should contain 'validation failed', got: %v", err)
71	}
72	if !strings.Contains(err.Error(), "empty soname") {
73		t.Fatalf("error message should contain 'empty soname', got: %v", err)
74	}
75}
76
77func TestLoadEmptyGroupNameReturnsError(t *testing.T) {
78	_, err := Load("testdata/empty_group_name.json")
79	if err == nil {
80		t.Fatal("expected error for empty group name, got nil")
81	}
82	if !strings.Contains(err.Error(), "validation failed") {
83		t.Fatalf("error message should contain 'validation failed', got: %v", err)
84	}
85	if !strings.Contains(err.Error(), "empty name") {
86		t.Fatalf("error message should contain 'empty name', got: %v", err)
87	}
88}
89
90func TestLoadEmptySymbolNameReturnsError(t *testing.T) {
91	_, err := Load("testdata/empty_symbol_name.json")
92	if err == nil {
93		t.Fatal("expected error for empty symbol name, got nil")
94	}
95	if !strings.Contains(err.Error(), "validation failed") {
96		t.Fatalf("error message should contain 'validation failed', got: %v", err)
97	}
98	if !strings.Contains(err.Error(), "empty name") {
99		t.Fatalf("error message should contain 'empty name', got: %v", err)
100	}
101}
102
103func TestLoadEmptySymbolSignatureReturnsError(t *testing.T) {
104	_, err := Load("testdata/empty_symbol_sig.json")
105	if err == nil {
106		t.Fatal("expected error for empty symbol signature, got nil")
107	}
108	if !strings.Contains(err.Error(), "validation failed") {
109		t.Fatalf("error message should contain 'validation failed', got: %v", err)
110	}
111	if !strings.Contains(err.Error(), "empty signature") {
112		t.Fatalf("error message should contain 'empty signature', got: %v", err)
113	}
114}
115
116func TestLoadEmptyCallbackNameReturnsError(t *testing.T) {
117	_, err := Load("testdata/empty_callback_name.json")
118	if err == nil {
119		t.Fatal("expected error for empty callback name, got nil")
120	}
121	if !strings.Contains(err.Error(), "validation failed") {
122		t.Fatalf("error message should contain 'validation failed', got: %v", err)
123	}
124	if !strings.Contains(err.Error(), "callback") || !strings.Contains(err.Error(), "empty name") {
125		t.Fatalf("error message should mention callback empty name, got: %v", err)
126	}
127}
128
129func TestLoadEmptyCallbackSignatureReturnsError(t *testing.T) {
130	_, err := Load("testdata/empty_callback_signature.json")
131	if err == nil {
132		t.Fatal("expected error for empty callback signature, got nil")
133	}
134	if !strings.Contains(err.Error(), "validation failed") {
135		t.Fatalf("error message should contain 'validation failed', got: %v", err)
136	}
137	if !strings.Contains(err.Error(), "callback") || !strings.Contains(err.Error(), "empty signature") {
138		t.Fatalf("error message should mention callback empty signature, got: %v", err)
139	}
140}
141
142func TestLoadEmptyEventStructNameReturnsError(t *testing.T) {
143	_, err := Load("testdata/empty_event_struct_name.json")
144	if err == nil {
145		t.Fatal("expected error for empty event struct name, got nil")
146	}
147	if !strings.Contains(err.Error(), "validation failed") {
148		t.Fatalf("error message should contain 'validation failed', got: %v", err)
149	}
150	if !strings.Contains(err.Error(), "event struct") || !strings.Contains(err.Error(), "empty name") {
151		t.Fatalf("error message should mention event struct empty name, got: %v", err)
152	}
153}
154
155func TestLoadCallbackWithUnknownGroupReturnsError(t *testing.T) {
156	_, err := Load("testdata/callback_unknown_group.json")
157	if err == nil {
158		t.Fatal("expected error for callback with unknown group, got nil")
159	}
160	if !strings.Contains(err.Error(), "validation failed") {
161		t.Fatalf("error message should contain 'validation failed', got: %v", err)
162	}
163	if !strings.Contains(err.Error(), "unknown group") {
164		t.Fatalf("error message should contain 'unknown group', got: %v", err)
165	}
166}

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 8

↑↓ moveenter openesc close