main 5041353

runtime_profile_test.go RawHistoryFolder

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

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