notice_test.go RawHistoryFolder

1package domain
2
3import (
4	"errors"
5	"fmt"
6	"testing"
7)
8
9func TestNoticeCodeString(t *testing.T) {
10	for code := range noticeCodeLimit {
11		if got := code.String(); got == "unknown" {
12			t.Errorf("NoticeCode(%d).String() = unknown, want declared code slug", code)
13		}
14	}
15	if got := NoticeCode(9999).String(); got != "unknown" {
16		t.Errorf("NoticeCode(9999).String() = %q, want unknown", got)
17	}
18}
19
20func TestUserError(t *testing.T) {
21	cause := errors.New("boom")
22	tests := []struct {
23		name     string
24		err      *UserError
25		wantMsg  string
26		wantSev  NoticeSeverity
27		wantWrap error
28	}{
29		{"err with cause", UserErr(NoticePaneSpawn, "couldn't open pane", cause), "couldn't open pane: boom", NoticeError, cause},
30		{"err without cause", UserErr(NoticeSessionUnavailable, "session is unavailable", nil), "session is unavailable", NoticeError, nil},
31		{"warn", UserWarn(NoticeResizeFailed, "pane resize failed", cause), "pane resize failed: boom", NoticeWarn, cause},
32	}
33	for _, tt := range tests {
34		t.Run(tt.name, func(t *testing.T) {
35			if got := tt.err.Error(); got != tt.wantMsg {
36				t.Errorf("Error() = %q, want %q", got, tt.wantMsg)
37			}
38			if tt.err.Severity != tt.wantSev {
39				t.Errorf("Severity = %d, want %d", tt.err.Severity, tt.wantSev)
40			}
41			if !errors.Is(tt.err, tt.wantWrap) && tt.wantWrap != nil {
42				t.Errorf("errors.Is(err, cause) = false, want true")
43			}
44			var ue *UserError
45			if !errors.As(fmt.Errorf("wrapped: %w", tt.err), &ue) {
46				t.Errorf("errors.As through wrapping = false, want true")
47			}
48		})
49	}
50}

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