mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-17 08:14:16 +00:00
fix(cliproxy): harden update recovery paths
This commit is contained in:
1 parent
8e4def4713
commit
4502e5d503
9 files changed
+318
-52
No files matched your search
@@ -10,6 +10,7 @@ function createDeps(
|
||||
sessionRunning?: boolean;
|
||||
remoteRunning?: boolean;
|
||||
startResult?: { started: boolean; alreadyRunning: boolean; port: number; error?: string };
|
||||
installError?: Error;
|
||||
} = {}
|
||||
) {
|
||||
const calls = {
|
||||
@@ -30,6 +31,7 @@ function createDeps(
|
||||
_backend?: CLIProxyBackend
|
||||
) => {
|
||||
calls.installCliproxyVersion += 1;
|
||||
if (overrides.installError) throw overrides.installError;
|
||||
},
|
||||
ensureCliproxyService: async () => {
|
||||
calls.ensureCliproxyService += 1;
|
||||
@@ -122,4 +124,16 @@ describe('installDashboardCliproxyVersion', () => {
|
||||
message: 'Installed CLIProxy Plus v6.7.1, but failed to restart it',
|
||||
});
|
||||
});
|
||||
|
||||
it('restores a previously running proxy when installation fails', async () => {
|
||||
const { deps, calls } = createDeps({
|
||||
sessionRunning: true,
|
||||
installError: new Error('checksum mismatch'),
|
||||
});
|
||||
|
||||
await expect(installDashboardCliproxyVersion('6.7.1', 'plus', deps)).rejects.toThrow(
|
||||
'checksum mismatch'
|
||||
);
|
||||
expect(calls.ensureCliproxyService).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user