fix: set canonical userData path during startup

This commit is contained in:
2026-03-09 23:52:50 -07:00
parent fed60c265d
commit 618727d8e8
5 changed files with 134 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
configureEarlyAppPaths,
normalizeStartupArgv,
normalizeLaunchMpvTargets,
sanitizeHelpEnv,
@@ -115,3 +116,30 @@ test('shouldDetachBackgroundLaunch only for first background invocation', () =>
);
assert.equal(shouldDetachBackgroundLaunch(['--start'], {}), false);
});
test('configureEarlyAppPaths pins userData to canonical SubMiner config dir', () => {
const calls: string[] = [];
const userDataPath = configureEarlyAppPaths(
{
setName: (name) => {
calls.push(`name:${name}`);
},
setPath: (key, value) => {
calls.push(`path:${key}:${value}`);
},
},
{
platform: 'linux',
homeDir: '/home/tester',
xdgConfigHome: '/tmp/xdg',
existsSync: (candidate) => candidate === '/tmp/xdg/subminer/config.jsonc',
},
);
assert.equal(userDataPath, '/tmp/xdg/SubMiner');
assert.deepEqual(calls, [
'name:SubMiner',
'path:userData:/tmp/xdg/SubMiner',
]);
});