Skip to content

Commit f342fcc

Browse files
Manyullyn17claude
andcommitted
test: the tests of going back no longer fail once MineShell is 1.0
They go back to 0.20.0 and 0.12.0, which only a 0.x may: from 1.0 on, MineShell goes back within its major and to the last 0.x. With package.json at 1.0.0 five of them failed, the release workflow's tests with them. They now run as 0.33.16 (pretendVersion, a seam like the other "for tests" ones); the major rule keeps its own test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 19fdd05 commit f342fcc

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎src/lib/server/selfupdate.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import crypto from 'node:crypto';
22
import fs from 'node:fs';
3-
import { afterEach, describe, expect, it, vi } from 'vitest';
3+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
44
import { fakeProcesses, spawnCalls } from '../../../tests/helpers/process';
55

66
// Installed or not is what the installer writes into the service's environment.
@@ -33,6 +33,7 @@ const {
3333
leftBehind,
3434
mayGoBackTo,
3535
planDowngrade,
36+
pretendVersion,
3637
releaseHistory,
3738
startDowngrade,
3839
startUpdate,
@@ -259,6 +260,12 @@ describe('the result, after the restart', () => {
259260
});
260261

261262
describe('going back to an older release', () => {
263+
// These go back to 0.20.0 and 0.12.0, which a 0.x may (any release, in beta); from 1.0 on only
264+
// the last 0.x may be gone back to ("from 1.0 on within the major", below). Without this they
265+
// failed once package.json said 1.0.0.
266+
beforeEach(() => pretendVersion('0.33.16'));
267+
afterEach(() => pretendVersion(null));
268+
262269
// The release list with 0.20.0 (migrations up to 0022) and 0.12.0 (before the accounts migration).
263270
async function listed() {
264271
latest = release(currentVersion());

‎src/lib/server/selfupdate.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,15 @@ export type Install = { home: string; config: string; service: string };
7070

7171
export class UpdateRefused extends Error {}
7272

73+
let pretended: string | null = null;
74+
7375
export function currentVersion(): string {
74-
return __MINESHELL_VERSION__;
76+
return pretended ?? __MINESHELL_VERSION__;
77+
}
78+
79+
/** For tests: the version this MineShell says it is, which decides where it may go back to; null undoes it. */
80+
export function pretendVersion(version: string | null): void {
81+
pretended = version;
7582
}
7683

7784
/** Where the installer put this MineShell; null when it runs from a source checkout. */

0 commit comments

Comments
 (0)