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}
32func TestCheckLegacyFormat_MixedEngineSectionReturnsMixedConfigError(t *testing.T) {
33	dir := t.TempDir()
34	configPath := filepath.Join(dir, "config.toml")
35	require.NoError(t, os.WriteFile(configPath, []byte("[engine]\nprofile = \"balanced\"\n\n[rendering]\ngsk_renderer = \"auto\"\n"), 0o600))
36
37	m := &Manager{viper: viper.New()}
38	m.viper.SetConfigFile(configPath)
39	m.viper.SetConfigType("toml")
40	require.NoError(t, m.viper.ReadInConfig())
41
42	err := m.checkLegacyFormat()
43
44	require.Error(t, err)
45	require.Contains(t, err.Error(), "mixed old/new config")
46	require.NotContains(t, err.Error(), "dumber config migrate")
47}
48
49func TestCheckLegacyFormat_FreshConfig_ReturnsNoError(t *testing.T) {
50	m := &Manager{viper: viper.New()}
51
52	err := m.checkLegacyFormat()
53
54	require.NoError(t, err)
55}
56
57func TestCheckLegacyFormat_DisableDmabuf_ReturnsError(t *testing.T) {
58	m := &Manager{viper: viper.New()}
59	m.viper.Set("rendering.disable_dmabuf_renderer", true)
60
61	err := m.checkLegacyFormat()
62
63	require.Error(t, err)
64	require.Contains(t, err.Error(), "dumber config migrate")
65}
66
67func TestCheckLegacyFormat_PerformanceProfile_ReturnsError(t *testing.T) {
68	m := &Manager{viper: viper.New()}
69	m.viper.Set("performance.profile", "lite")
70
71	err := m.checkLegacyFormat()
72
73	require.Error(t, err)
74	require.Contains(t, err.Error(), "dumber config migrate")
75}
76
77func TestCheckLegacyFormat_PrivacyCookiePolicy_ReturnsError(t *testing.T) {
78	m := &Manager{viper: viper.New()}
79	m.viper.Set("privacy.cookie_policy", "always")
80
81	err := m.checkLegacyFormat()
82
83	require.Error(t, err)
84	require.Contains(t, err.Error(), "dumber config migrate")
85}
86
87func TestCheckLegacyFormat_RuntimePrefix_ReturnsError(t *testing.T) {
88	m := &Manager{viper: viper.New()}
89	m.viper.Set("runtime.prefix", "/usr")
90
91	err := m.checkLegacyFormat()
92
93	require.Error(t, err)
94	require.Contains(t, err.Error(), "dumber config migrate")
95}
96
97func TestCheckLegacyFormat_MetadataBackedAliasesReturnError(t *testing.T) {
98	for _, alias := range legacyEngineAliases {
99		key := alias.legacyKey()
100		t.Run(key, func(t *testing.T) {
101			m := &Manager{viper: viper.New()}
102			m.viper.Set(key, sampleLegacyAliasValue(alias))
103
104			err := m.checkLegacyFormat()
105
106			require.Error(t, err)
107			require.Contains(t, err.Error(), "dumber config migrate")
108		})
109	}
110}
111
112func sampleLegacyAliasValue(alias legacyEngineAlias) any {
113	switch alias.legacyKey() {
114	case "performance.profile":
115		return "balanced"
116	case "privacy.cookie_policy":
117		return "always"
118	case "rendering.mode":
119		return "gpu"
120	case "rendering.gsk_renderer", "media.gl_rendering_mode":
121		return "auto"
122	case "runtime.prefix":
123		return "/usr"
124	}
125
126	switch alias.legacyField {
127	case "zoom_cache_size", "webview_pool_prewarm_count",
128		"skia_cpu_painting_threads", "skia_gpu_painting_threads",
129		"web_process_memory_limit_mb", "network_process_memory_limit_mb",
130		"gstreamer_debug_level":
131		return 1
132	case "web_process_memory_poll_interval_sec", "network_process_memory_poll_interval_sec",
133		"web_process_memory_conservative_threshold", "web_process_memory_strict_threshold",
134		"network_process_memory_conservative_threshold", "network_process_memory_strict_threshold":
135		return 0.5
136	default:
137		return true
138	}
139}
140
141func TestTransformLegacyConfig_DefaultAdaptiveDoesNotBlockLegacyCEFMigration(t *testing.T) {
142	dir := t.TempDir()
143	configPath := filepath.Join(dir, "config.toml")
144	require.NoError(t, os.WriteFile(configPath, []byte("[engine.cef]\nwindowless_frame_rate = 60\n"), 0o600))
145
146	m := &Manager{viper: viper.New()}
147	m.viper.SetConfigFile(configPath)
148	m.viper.SetConfigType("toml")
149	m.setDefaults()
150	require.NoError(t, m.viper.ReadInConfig())
151
152	m.transformLegacyConfig()
153
154	require.True(t, m.viper.GetBool("engine.cef.adaptive_windowless_frame_rate"))
155	require.Equal(t, 0, m.viper.GetInt("engine.cef.windowless_frame_rate"))
156	require.Equal(t, defaultCEFWindowlessFrameRateMax, m.viper.GetInt("engine.cef.windowless_frame_rate_max"))
157}
158
159func TestTransformLegacyConfig_ExplicitAdaptiveEnvOverrideBlocksLegacyCEFMigration(t *testing.T) {
160	dir := t.TempDir()
161	configPath := filepath.Join(dir, "config.toml")
162	require.NoError(t, os.WriteFile(configPath, []byte("[engine.cef]\nwindowless_frame_rate = 60\n"), 0o600))
163	t.Setenv("DUMBER_ENGINE_CEF_ADAPTIVE_WINDOWLESS_FRAME_RATE", "false")
164
165	m := &Manager{viper: viper.New()}
166	m.viper.SetConfigFile(configPath)
167	m.viper.SetConfigType("toml")
168	m.configureAutomaticEnv()
169	m.setDefaults()
170	require.NoError(t, m.viper.ReadInConfig())
171
172	m.transformLegacyConfig()
173
174	require.False(t, m.viper.GetBool("engine.cef.adaptive_windowless_frame_rate"))
175	require.Equal(t, 60, m.viper.GetInt("engine.cef.windowless_frame_rate"))
176}
177
178func TestTransformLegacyConfig_UnconfiguredManagerIgnoresAmbientAdaptiveEnv(t *testing.T) {
179	dir := t.TempDir()
180	configPath := filepath.Join(dir, "config.toml")
181	require.NoError(t, os.WriteFile(configPath, []byte("[engine.cef]\nwindowless_frame_rate = 60\n"), 0o600))
182	t.Setenv("DUMBER_ENGINE_CEF_ADAPTIVE_WINDOWLESS_FRAME_RATE", "false")
183
184	m := &Manager{viper: viper.New()}
185	m.viper.SetConfigFile(configPath)
186	m.viper.SetConfigType("toml")
187	m.setDefaults()
188	require.NoError(t, m.viper.ReadInConfig())
189
190	m.transformLegacyConfig()
191
192	require.True(t, m.viper.GetBool("engine.cef.adaptive_windowless_frame_rate"))
193	require.Equal(t, 0, m.viper.GetInt("engine.cef.windowless_frame_rate"))
194}
195
196func TestTransformLegacyConfig_ExplicitAdaptiveEnvTrueMigratesLegacyCEFDefault(t *testing.T) {
197	dir := t.TempDir()
198	configPath := filepath.Join(dir, "config.toml")
199	require.NoError(t, os.WriteFile(configPath, []byte("[engine.cef]\nwindowless_frame_rate = 60\n"), 0o600))
200	t.Setenv("DUMBER_ENGINE_CEF_ADAPTIVE_WINDOWLESS_FRAME_RATE", "true")
201
202	m := &Manager{viper: viper.New()}
203	m.viper.SetConfigFile(configPath)
204	m.viper.SetConfigType("toml")
205	m.configureAutomaticEnv()
206	m.setDefaults()
207	require.NoError(t, m.viper.ReadInConfig())
208
209	m.transformLegacyConfig()
210
211	require.True(t, m.viper.GetBool("engine.cef.adaptive_windowless_frame_rate"))
212	require.Equal(t, 0, m.viper.GetInt("engine.cef.windowless_frame_rate"))
213	require.Equal(t, defaultCEFWindowlessFrameRateMax, m.viper.GetInt("engine.cef.windowless_frame_rate_max"))
214}

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