v0.30.0 eb3068f

engine_test.go RawHistoryFolder

1package bootstrap
2
3import (
4	"context"
5	"path/filepath"
6	"testing"
7
8	"github.com/bnema/dumber/internal/infrastructure/cef"
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 TestBuildEngine_UnknownType(t *testing.T) {
15	cfg := config.DefaultConfig()
16	cfg.Engine.Type = "unknown"
17	_, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background()})
18	require.Error(t, err)
19	require.Contains(t, err.Error(), "unknown engine type")
20}
21
22func TestBuildEngine_CEF_ReturnsErrorWhenRuntimeUnavailable(t *testing.T) {
23	cfg := config.DefaultConfig()
24	cfg.Engine.Type = "cef"
25	cfg.Engine.CEF.CEFDir = t.TempDir()
26	_, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background(), RuntimeProfile: testRuntimeProfile(t)})
27	require.Error(t, err)
28	require.Contains(t, err.Error(), "cef.InitWithApp")
29}
30
31func TestBuildEngine_CEF_ReturnsErrorForUnsupportedCookiePolicy(t *testing.T) {
32	cfg := config.DefaultConfig()
33	cfg.Engine.Type = "cef"
34	cfg.Engine.CookiePolicy = config.CookiePolicyNever
35	_, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background(), RuntimeProfile: testRuntimeProfile(t)})
36	require.ErrorIs(t, err, cef.ErrCookiePolicyUnsupported)
37}
38
39func TestBuildEngine_CEF_AllowsNoThirdPartyCookiePolicy(t *testing.T) {
40	cfg := config.DefaultConfig()
41	cfg.Engine.Type = "cef"
42	cfg.Engine.CookiePolicy = config.CookiePolicyNoThirdParty
43	cfg.Engine.CEF.CEFDir = t.TempDir()
44	_, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background(), RuntimeProfile: testRuntimeProfile(t)})
45	require.NotErrorIs(t, err, cef.ErrCookiePolicyUnsupported)
46}
47
48func TestBuildEngine_ReceivesResolvedProfile(t *testing.T) {
49	cfg := config.DefaultConfig()
50	cfg.Engine.Type = config.EngineTypeCEF
51	cfg.Engine.CEF.CEFDir = t.TempDir()
52
53	_, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background(), RuntimeProfile: testRuntimeProfile(t)})
54	require.Error(t, err)
55	require.NotContains(t, err.Error(), "missing runtime profile")
56}
57
58func testRuntimeProfile(t *testing.T) runtimeprofile.Profile {
59	t.Helper()
60	root := t.TempDir()
61	profile, err := runtimeprofile.Resolve(runtimeprofile.ResolveInput{
62		Env:    func(string) string { return "" },
63		Engine: config.EngineTypeCEF,
64		CWD:    func() (string, error) { return root, nil },
65		Base: runtimeprofile.BasePaths{
66			ConfigHome: filepath.Join(root, "config"),
67			DataHome:   filepath.Join(root, "data"),
68			StateHome:  filepath.Join(root, "state"),
69			CacheHome:  filepath.Join(root, "cache"),
70		},
71	})
72	require.NoError(t, err)
73	return profile
74}

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