command_test.go RawHistoryFolder

1package command
2
3import (
4	"errors"
5	"testing"
6)
7
8func TestParsePositiveUint64(t *testing.T) {
9	for _, tt := range []struct {
10		name    string
11		args    []string
12		want    uint64
13		invalid bool
14	}{
15		{name: "maximum", args: []string{"18446744073709551615"}, want: ^uint64(0)},
16		{name: "overflow", args: []string{"18446744073709551616"}, invalid: true},
17		{name: "zero", args: []string{"0"}, invalid: true},
18		{name: "leading zero", args: []string{"01"}, invalid: true},
19		{name: "empty string", args: []string{""}, invalid: true},
20		{name: "positive sign", args: []string{"+1"}, invalid: true},
21		{name: "negative sign", args: []string{"-1"}, invalid: true},
22		{name: "whitespace", args: []string{"1 2"}, invalid: true},
23		{name: "non-digit", args: []string{"1x"}, invalid: true},
24		{name: "empty arguments", invalid: true},
25		{name: "multiple arguments", args: []string{"1", "2"}, invalid: true},
26	} {
27		t.Run(tt.name, func(t *testing.T) {
28			got, err := ParsePositiveUint64(tt.args)
29			if tt.invalid {
30				if !errors.Is(err, ErrInvalidArguments) {
31					t.Fatalf("error = %v", err)
32				}
33				return
34			}
35			if err != nil || got != tt.want {
36				t.Fatalf("ParsePositiveUint64() = %d, %v", got, err)
37			}
38		})
39	}
40}
41
42func TestParsePositiveDecimal(t *testing.T) {
43	for _, tt := range []struct {
44		name    string
45		args    []string
46		want    int
47		invalid bool
48	}{
49		{"one", []string{"1"}, 1, false},
50		{"multi-digit", []string{"42"}, 42, false},
51		{"overflow", []string{"999999999999999999999999999999999999"}, 0, true},
52		{"leading zero", []string{"01"}, 0, true},
53		{"multiple leading zeros", []string{"0001"}, 0, true},
54		{"all zeros", []string{"00"}, 0, true},
55		{"leading zero on multi-digit value", []string{"010"}, 0, true},
56		{"zero", []string{"0"}, 0, true},
57		{"negative", []string{"-1"}, 0, true},
58		{"extra", []string{"1", "2"}, 0, true},
59		{"space", []string{" 1"}, 0, true},
60	} {
61		t.Run(tt.name, func(t *testing.T) {
62			got, err := ParsePositiveDecimal(tt.args)
63			if tt.invalid {
64				if !errors.Is(err, ErrInvalidArguments) {
65					t.Fatalf("error = %v", err)
66				}
67				return
68			}
69			if err != nil || got != tt.want {
70				t.Fatalf("ParsePositiveDecimal() = %d, %v", got, err)
71			}
72		})
73	}
74}

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