v0.33.0 62a09f5

policy_test.go RawHistoryFolder

1package download
2
3import "testing"
4
5func TestShouldForceDownloadForURI(t *testing.T) {
6	tests := []struct {
7		name     string
8		uri      string
9		expected bool
10	}{
11		{name: "pdf path", uri: "https://example.com/file.pdf", expected: true},
12		{name: "iso path", uri: "https://example.com/linux.iso?mirror=1", expected: true},
13		{name: "archive path", uri: "https://example.com/release.tar.gz", expected: true},
14		{name: "plain html", uri: "https://example.com/index.html", expected: false},
15		{name: "empty", uri: "", expected: false},
16	}
17
18	for _, tt := range tests {
19		t.Run(tt.name, func(t *testing.T) {
20			if got := ShouldForceDownloadForURI(tt.uri); got != tt.expected {
21				t.Fatalf("ShouldForceDownloadForURI(%q) = %v, want %v", tt.uri, got, tt.expected)
22			}
23		})
24	}
25}
26
27func TestShouldForceDownloadForMIMEType(t *testing.T) {
28	tests := []struct {
29		name     string
30		mimeType string
31		expected bool
32	}{
33		{name: "pdf", mimeType: "application/pdf", expected: true},
34		{name: "pdf with params", mimeType: "application/pdf; charset=binary", expected: true},
35		{name: "iso image", mimeType: "application/x-iso9660-image", expected: true},
36		{name: "html", mimeType: "text/html", expected: false},
37		{name: "empty", mimeType: "", expected: false},
38	}
39
40	for _, tt := range tests {
41		t.Run(tt.name, func(t *testing.T) {
42			if got := ShouldForceDownloadForMIMEType(tt.mimeType); got != tt.expected {
43				t.Fatalf("ShouldForceDownloadForMIMEType(%q) = %v, want %v", tt.mimeType, got, tt.expected)
44			}
45		})
46	}
47}
48
49func TestShouldForceDownload(t *testing.T) {
50	if !ShouldForceDownload("https://example.com/file.iso", "") {
51		t.Fatal("expected URI extension to trigger forced download")
52	}
53	if !ShouldForceDownload("", "application/pdf") {
54		t.Fatal("expected MIME type to trigger forced download")
55	}
56	if ShouldForceDownload("https://example.com/", "text/html") {
57		t.Fatal("did not expect regular HTML to trigger forced download")
58	}
59}

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 8

Tags 42

↑↓ moveenter openesc close