v0.29.0 21b3150

runtime_profile_test.go RawHistoryFolder

1package bootstrap
2
3import (
4	"path/filepath"
5	"testing"
6
7	"github.com/bnema/dumber/internal/infrastructure/config"
8	"github.com/bnema/dumber/internal/infrastructure/runtimeprofile"
9	"github.com/stretchr/testify/require"
10)
11
12func TestResolveRuntimeProfile_UsesConfigEngineResolution(t *testing.T) {
13	cfg := config.DefaultConfig()
14	cfg.Engine.Type = "webkit"
15	t.Setenv("DUMBER_ENGINE", "cef")
16	t.Setenv("ENV", "")
17	home := t.TempDir()
18	t.Setenv("HOME", home)
19	t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
20	t.Setenv("XDG_DATA_HOME", filepath.Join(home, ".local", "share"))
21	t.Setenv("XDG_STATE_HOME", filepath.Join(home, ".local", "state"))
22	t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
23
24	profile, err := ResolveRuntimeProfile(cfg)
25	require.NoError(t, err)
26	require.Equal(t, "cef", profile.Engine)
27}
28
29func TestResolveRuntimeProfile_ProdPreservesSharedPaths(t *testing.T) {
30	cfg := config.DefaultConfig()
31	cfg.Engine.Type = config.EngineTypeWebKit
32	t.Setenv("ENV", "")
33	home := t.TempDir()
34	t.Setenv("HOME", home)
35	t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
36	t.Setenv("XDG_DATA_HOME", filepath.Join(home, ".local", "share"))
37	t.Setenv("XDG_STATE_HOME", filepath.Join(home, ".local", "state"))
38	t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
39
40	profile, err := ResolveRuntimeProfile(cfg)
41	require.NoError(t, err)
42	require.Equal(t, filepath.Join(home, ".config", "dumber"), profile.Shared.ConfigDir)
43	require.Equal(t, filepath.Join(home, ".local", "share", "dumber"), profile.Shared.DataDir)
44	require.Equal(t, filepath.Join(home, ".local", "state", "dumber"), profile.Shared.StateDir)
45	require.Equal(t, filepath.Join(home, ".cache", "dumber"), profile.Shared.CacheDir)
46}
47
48func TestResolveRuntimeProfile_DevUsesEngineSpecificNamespaces(t *testing.T) {
49	cfg := config.DefaultConfig()
50	cfg.Engine.Type = config.EngineTypeCEF
51
52	wd := t.TempDir()
53	t.Chdir(wd)
54
55	t.Setenv("ENV", "dev")
56	profile, err := ResolveRuntimeProfile(cfg)
57	require.NoError(t, err)
58	require.Equal(t, filepath.Join(wd, ".dev", "dumber", "state"), profile.Shared.StateDir)
59	require.Equal(t, filepath.Join(wd, ".dev", "dumber", "engines", "cef", "data"), profile.CEFUserDataDir())
60	require.Equal(t, filepath.Join(wd, ".dev", "dumber", "runtime", "cef", "browser-launch.sock"), profile.IPC.BrowserLaunchSocket)
61}
62
63func TestResolveXDGRuntimeDir_UsesSharedRuntimeRootInDev(t *testing.T) {
64	profile := runtimeprofile.Profile{
65		Mode: runtimeprofile.ModeDev,
66		Shared: runtimeprofile.SharedPaths{
67			RootDir:  "/tmp/project/.dev/dumber",
68			StateDir: "/tmp/project/.dev/dumber/state",
69		},
70	}
71
72	require.Equal(t, "/tmp/project/.dev/dumber/runtime", ResolveXDGRuntimeDir(profile))
73}
74
75func TestResolveXDGRuntimeDir_UsesStateRuntimeRootInProd(t *testing.T) {
76	profile := runtimeprofile.Profile{
77		Mode: runtimeprofile.ModeProd,
78		Shared: runtimeprofile.SharedPaths{
79			StateDir: "/tmp/dumber-state/dumber",
80		},
81	}
82
83	require.Equal(t, "/tmp/dumber-state/dumber/runtime", ResolveXDGRuntimeDir(profile))
84}

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