v0.3.0 cf370a0

registry_test.go RawHistoryFolder

1package screensaver
2
3import "testing"
4
5func TestRegistry(t *testing.T) {
6	r := newRegistry()
7	a1, first, ok := r.inhibit(":1.1")
8	if !ok || !first || !r.held() {
9		t.Fatal("first inhibit")
10	}
11	a2, first, _ := r.inhibit(":1.1")
12	if first || a2 == a1 {
13		t.Fatalf("second inhibit: first %v, cookies %d %d", first, a1, a2)
14	}
15	b, first, _ := r.inhibit(":1.2")
16	if !first {
17		t.Fatal("other sender not first")
18	}
19	// Another connection cannot release a cookie it does not own.
20	if r.uninhibit(":1.2", a1) || r.uninhibit(":1.1", 999) {
21		t.Fatal("foreign or unknown cookie released")
22	}
23	if !r.uninhibit(":1.1", a1) || !r.held() {
24		t.Fatal("uninhibit")
25	}
26	r.drop(":1.1")
27	if !r.held() {
28		t.Fatal("drop removed another sender's cookie")
29	}
30	if !r.uninhibit(":1.2", b) || r.held() {
31		t.Fatal("still held")
32	}
33	if _, first, _ := r.inhibit(":1.1"); !first {
34		t.Fatal("dropped sender is not first again")
35	}
36}
37
38func TestRegistryBoundsSender(t *testing.T) {
39	r := newRegistry()
40	for range maxPerSender {
41		if _, _, ok := r.inhibit(":1.1"); !ok {
42			t.Fatal("refused under the bound")
43		}
44	}
45	if _, _, ok := r.inhibit(":1.1"); ok {
46		t.Fatal("accepted over the bound")
47	}
48	if _, _, ok := r.inhibit(":1.2"); !ok {
49		t.Fatal("bound is per sender")
50	}
51}
52
53func TestRegistryCookieWrapSkipsZeroAndUsed(t *testing.T) {
54	r := newRegistry()
55	r.next = ^uint32(0) - 1
56	c1, _, _ := r.inhibit(":1.1") // max
57	c2, _, _ := r.inhibit(":1.1") // wraps past 0
58	if c1 != ^uint32(0) || c2 != 1 {
59		t.Fatalf("cookies %d %d", c1, c2)
60	}
61	r.next = 0
62	if c3, _, _ := r.inhibit(":1.1"); c3 != 2 {
63		t.Fatalf("reused cookie %d", c3)
64	}
65}

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 23

Tags 10

↑↓ moveenter openesc close