v0.3.21 7fe8dbc

socketpath_test.go RawHistoryFolder

1package swarm
2
3import (
4	"os"
5	"path/filepath"
6	"runtime"
7	"strings"
8	"testing"
9)
10
11func TestInboxSocketPathUsesRuntimeDirectory(t *testing.T) {
12	if runtime.GOOS == "windows" {
13		t.Skip("swarm inbox transport uses Unix-domain sockets")
14	}
15
16	runtimeDir := shortSocketDir(t)
17	stateRoot := filepath.Join(t.TempDir(), "state")
18	t.Setenv("XDG_RUNTIME_DIR", runtimeDir)
19
20	path, err := inboxSocketPath(stateRoot, "agent-123")
21	if err != nil {
22		t.Fatalf("inboxSocketPath: %v", err)
23	}
24	if !strings.HasPrefix(path, runtimeDir+string(filepath.Separator)) {
25		t.Fatalf("path = %q; want it below runtime dir %q", path, runtimeDir)
26	}
27	if strings.HasPrefix(path, stateRoot+string(filepath.Separator)) {
28		t.Fatalf("path = %q; transient socket must not be below state root %q", path, stateRoot)
29	}
30}
31
32func TestInboxSocketPathFallsBackFromUnusableRuntimeDirectory(t *testing.T) {
33	if runtime.GOOS == "windows" {
34		t.Skip("swarm inbox transport uses Unix-domain sockets")
35	}
36
37	badRuntime := filepath.Join(shortSocketDir(t), "not-a-directory")
38	if err := os.WriteFile(badRuntime, []byte("x"), 0o600); err != nil {
39		t.Fatal(err)
40	}
41	tempDir := shortSocketDir(t)
42	t.Setenv("XDG_RUNTIME_DIR", badRuntime)
43	t.Setenv("TMPDIR", tempDir)
44
45	path, err := inboxSocketPath(t.TempDir(), "agent-456")
46	if err != nil {
47		t.Fatalf("inboxSocketPath: %v", err)
48	}
49	if !strings.HasPrefix(path, tempDir+string(filepath.Separator)) {
50		t.Fatalf("path = %q; want fallback below %q", path, tempDir)
51	}
52}
53
54func TestInboxSocketPathShortensLongAgentID(t *testing.T) {
55	if runtime.GOOS == "windows" {
56		t.Skip("swarm inbox transport uses Unix-domain sockets")
57	}
58
59	t.Setenv("XDG_RUNTIME_DIR", shortSocketDir(t))
60	path, err := inboxSocketPath(t.TempDir(), strings.Repeat("agent", 100))
61	if err != nil {
62		t.Fatalf("inboxSocketPath: %v", err)
63	}
64	if len(path) > maxUnixSocketPath {
65		t.Fatalf("socket path length = %d; want <= %d: %q", len(path), maxUnixSocketPath, path)
66	}
67}

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 476

↑↓ moveenter openesc close