v2.31.0-dev8 ec8c5b9

run_test.go RawHistoryFolder

1package app
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7
8	"github.com/stretchr/testify/assert"
9)
10
11func TestResolveRuntimeConfig(t *testing.T) {
12	tests := []struct {
13		name       string
14		value      string
15		xdgDir     string // non-empty means set XDG_RUNTIME_DIR
16		createSock bool   // whether to create the socket file under xdgDir
17		want       string
18	}{
19		{
20			name:  "empty string returns empty",
21			value: "",
22			want:  "",
23		},
24		{
25			name:  "auto returns empty",
26			value: "auto",
27			want:  "",
28		},
29		{
30			name:       "podman with XDG_RUNTIME_DIR and socket present",
31			value:      "podman",
32			xdgDir:     "tmpXDG", // replaced with t.TempDir() in the loop
33			createSock: true,
34		},
35		{
36			name:   "podman with XDG_RUNTIME_DIR but socket absent falls back to system socket",
37			value:  "podman",
38			xdgDir: "tmpXDG",
39			want:   "/run/podman/podman.sock",
40		},
41		{
42			name:  "podman without XDG_RUNTIME_DIR falls back to system socket",
43			value: "podman",
44			want:  "/run/podman/podman.sock",
45		},
46		{
47			name:  "docker returns well-known path",
48			value: "docker",
49			want:  "/var/run/docker.sock",
50		},
51		{
52			name:  "unix:// prefix is stripped",
53			value: "unix:///custom/path.sock",
54			want:  "/custom/path.sock",
55		},
56		{
57			name:  "bare path returned as-is",
58			value: "/custom/path.sock",
59			want:  "/custom/path.sock",
60		},
61	}
62
63	for _, tt := range tests {
64		t.Run(tt.name, func(t *testing.T) {
65			xdgDir := tt.xdgDir
66			if xdgDir == "tmpXDG" {
67				xdgDir = t.TempDir()
68			}
69
70			if xdgDir != "" {
71				t.Setenv("XDG_RUNTIME_DIR", xdgDir)
72			} else {
73				t.Setenv("XDG_RUNTIME_DIR", "")
74			}
75
76			want := tt.want
77			if tt.createSock && xdgDir != "" {
78				sockDir := filepath.Join(xdgDir, "podman")
79				os.MkdirAll(sockDir, 0o755)
80				os.WriteFile(filepath.Join(sockDir, "podman.sock"), nil, 0o600)
81				want = filepath.Join(xdgDir, "podman", "podman.sock")
82			}
83
84			got := resolveRuntimeConfig(tt.value)
85			assert.Equal(t, want, got)
86		})
87	}
88}

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 7

Tags 106

↑↓ moveenter openesc close