main 5041353

adapter_test.go RawHistoryFolder

1package xdg
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7
8	"github.com/stretchr/testify/assert"
9	"github.com/stretchr/testify/require"
10)
11
12func TestAdapter_DownloadDir(t *testing.T) {
13	adapter := New(false, "")
14
15	t.Run("returns XDG_DOWNLOAD_DIR when set", func(t *testing.T) {
16		t.Setenv("XDG_DOWNLOAD_DIR", "/custom/downloads")
17
18		dir, err := adapter.DownloadDir()
19
20		require.NoError(t, err)
21		assert.Equal(t, "/custom/downloads", dir)
22	})
23
24	t.Run("falls back to ~/Downloads when XDG_DOWNLOAD_DIR not set", func(t *testing.T) {
25		t.Setenv("XDG_DOWNLOAD_DIR", "")
26
27		dir, err := adapter.DownloadDir()
28
29		require.NoError(t, err)
30
31		home, err := os.UserHomeDir()
32		require.NoError(t, err)
33
34		expected := filepath.Join(home, "Downloads")
35		assert.Equal(t, expected, dir)
36	})
37}
38
39func TestAdapter_RuntimeDir(t *testing.T) {
40	t.Run("returns XDG_RUNTIME_DIR when set outside dev", func(t *testing.T) {
41		adapter := New(false, "")
42		t.Setenv("XDG_RUNTIME_DIR", "/custom/runtime")
43
44		dir, err := adapter.RuntimeDir()
45
46		require.NoError(t, err)
47		assert.Equal(t, "/custom/runtime", dir)
48	})
49
50	t.Run("falls back to injected prod runtime dir when XDG_RUNTIME_DIR not set", func(t *testing.T) {
51		adapter := New(false, "/tmp/dumber-state/dumber/runtime")
52		t.Setenv("XDG_RUNTIME_DIR", "")
53
54		dir, err := adapter.RuntimeDir()
55
56		require.NoError(t, err)
57		assert.Equal(t, "/tmp/dumber-state/dumber/runtime", dir)
58	})
59
60	t.Run("uses injected sandbox runtime dir in dev even when XDG_RUNTIME_DIR is set", func(t *testing.T) {
61		wd := t.TempDir()
62		adapter := New(true, filepath.Join(wd, ".dev", "dumber", "runtime"))
63		t.Setenv("XDG_RUNTIME_DIR", "/shared/runtime")
64
65		dir, err := adapter.RuntimeDir()
66
67		require.NoError(t, err)
68		assert.Equal(t, filepath.Join(wd, ".dev", "dumber", "runtime"), dir)
69	})
70}
71
72func TestNew(t *testing.T) {
73	adapter := New(false, "")
74
75	assert.NotNil(t, adapter)
76}

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