v0.29.0 21b3150

loader_legacy_test.go RawHistoryFolder

1package config
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7
8	"github.com/spf13/viper"
9	"github.com/stretchr/testify/require"
10)
11
12func TestCheckLegacyFormat_OldSectionsNoEngine_ReturnsError(t *testing.T) {
13	m := &Manager{viper: viper.New()}
14	m.viper.Set("rendering.mode", "gpu")
15
16	err := m.checkLegacyFormat()
17
18	require.Error(t, err)
19	require.Contains(t, err.Error(), "dumber config migrate")
20}
21
22func TestCheckLegacyFormat_OldSectionsWithEngine_ReturnsError(t *testing.T) {
23	m := &Manager{viper: viper.New()}
24	m.viper.Set("rendering.mode", "gpu")
25	m.viper.Set("engine.type", "webkit")
26
27	err := m.checkLegacyFormat()
28
29	require.Error(t, err)
30	require.Contains(t, err.Error(), "dumber config migrate")
31}
32
33func TestCheckLegacyFormat_FreshConfig_ReturnsNoError(t *testing.T) {
34	m := &Manager{viper: viper.New()}
35
36	err := m.checkLegacyFormat()
37
38	require.NoError(t, err)
39}
40
41func TestCheckLegacyFormat_DisableDmabuf_ReturnsError(t *testing.T) {
42	m := &Manager{viper: viper.New()}
43	m.viper.Set("rendering.disable_dmabuf_renderer", true)
44
45	err := m.checkLegacyFormat()
46
47	require.Error(t, err)
48	require.Contains(t, err.Error(), "dumber config migrate")
49}
50
51func TestCheckLegacyFormat_PerformanceProfile_ReturnsError(t *testing.T) {
52	m := &Manager{viper: viper.New()}
53	m.viper.Set("performance.profile", "lite")
54
55	err := m.checkLegacyFormat()
56
57	require.Error(t, err)
58	require.Contains(t, err.Error(), "dumber config migrate")
59}
60
61func TestCheckLegacyFormat_PrivacyCookiePolicy_ReturnsError(t *testing.T) {
62	m := &Manager{viper: viper.New()}
63	m.viper.Set("privacy.cookie_policy", "always")
64
65	err := m.checkLegacyFormat()
66
67	require.Error(t, err)
68	require.Contains(t, err.Error(), "dumber config migrate")
69}
70
71func TestCheckLegacyFormat_RuntimePrefix_ReturnsError(t *testing.T) {
72	m := &Manager{viper: viper.New()}
73	m.viper.Set("runtime.prefix", "/usr")
74
75	err := m.checkLegacyFormat()
76
77	require.Error(t, err)
78	require.Contains(t, err.Error(), "dumber config migrate")
79}
80
81func TestTransformLegacyConfig_DefaultAdaptiveDoesNotBlockLegacyCEFMigration(t *testing.T) {
82	dir := t.TempDir()
83	configPath := filepath.Join(dir, "config.toml")
84	require.NoError(t, os.WriteFile(configPath, []byte("[engine.cef]\nwindowless_frame_rate = 60\n"), 0o600))
85
86	m := &Manager{viper: viper.New()}
87	m.viper.SetConfigFile(configPath)
88	m.viper.SetConfigType("toml")
89	m.setDefaults()
90	require.NoError(t, m.viper.ReadInConfig())
91
92	m.transformLegacyConfig()
93
94	require.True(t, m.viper.GetBool("engine.cef.adaptive_windowless_frame_rate"))
95	require.Equal(t, 0, m.viper.GetInt("engine.cef.windowless_frame_rate"))
96	require.Equal(t, defaultCEFWindowlessFrameRateMax, m.viper.GetInt("engine.cef.windowless_frame_rate_max"))
97}
98
99func TestTransformLegacyConfig_ExplicitAdaptiveEnvOverrideBlocksLegacyCEFMigration(t *testing.T) {
100	dir := t.TempDir()
101	configPath := filepath.Join(dir, "config.toml")
102	require.NoError(t, os.WriteFile(configPath, []byte("[engine.cef]\nwindowless_frame_rate = 60\n"), 0o600))
103	t.Setenv("DUMBER_ENGINE_CEF_ADAPTIVE_WINDOWLESS_FRAME_RATE", "false")
104
105	m := &Manager{viper: viper.New()}
106	m.viper.SetConfigFile(configPath)
107	m.viper.SetConfigType("toml")
108	m.configureAutomaticEnv()
109	m.setDefaults()
110	require.NoError(t, m.viper.ReadInConfig())
111
112	m.transformLegacyConfig()
113
114	require.False(t, m.viper.GetBool("engine.cef.adaptive_windowless_frame_rate"))
115	require.Equal(t, 60, m.viper.GetInt("engine.cef.windowless_frame_rate"))
116}
117
118func TestTransformLegacyConfig_UnconfiguredManagerIgnoresAmbientAdaptiveEnv(t *testing.T) {
119	dir := t.TempDir()
120	configPath := filepath.Join(dir, "config.toml")
121	require.NoError(t, os.WriteFile(configPath, []byte("[engine.cef]\nwindowless_frame_rate = 60\n"), 0o600))
122	t.Setenv("DUMBER_ENGINE_CEF_ADAPTIVE_WINDOWLESS_FRAME_RATE", "false")
123
124	m := &Manager{viper: viper.New()}
125	m.viper.SetConfigFile(configPath)
126	m.viper.SetConfigType("toml")
127	m.setDefaults()
128	require.NoError(t, m.viper.ReadInConfig())
129
130	m.transformLegacyConfig()
131
132	require.True(t, m.viper.GetBool("engine.cef.adaptive_windowless_frame_rate"))
133	require.Equal(t, 0, m.viper.GetInt("engine.cef.windowless_frame_rate"))
134}
135
136func TestTransformLegacyConfig_ExplicitAdaptiveEnvTrueMigratesLegacyCEFDefault(t *testing.T) {
137	dir := t.TempDir()
138	configPath := filepath.Join(dir, "config.toml")
139	require.NoError(t, os.WriteFile(configPath, []byte("[engine.cef]\nwindowless_frame_rate = 60\n"), 0o600))
140	t.Setenv("DUMBER_ENGINE_CEF_ADAPTIVE_WINDOWLESS_FRAME_RATE", "true")
141
142	m := &Manager{viper: viper.New()}
143	m.viper.SetConfigFile(configPath)
144	m.viper.SetConfigType("toml")
145	m.configureAutomaticEnv()
146	m.setDefaults()
147	require.NoError(t, m.viper.ReadInConfig())
148
149	m.transformLegacyConfig()
150
151	require.True(t, m.viper.GetBool("engine.cef.adaptive_windowless_frame_rate"))
152	require.Equal(t, 0, m.viper.GetInt("engine.cef.windowless_frame_rate"))
153	require.Equal(t, defaultCEFWindowlessFrameRateMax, m.viper.GetInt("engine.cef.windowless_frame_rate_max"))
154}

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