mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-08 04:03:41 +08:00
Use MikroORM's official Node SQLite dialect with bounded database isolation, preserve legacy schema and data for rollback, and require Node 22.17 or newer. Update Debian runtimes and retain ARMv6 musl compatibility without a SQLite addon. Complete short archive writes, stop orphaned SQL workers after owner death, preserve buffered startup requests, and prestart the archived backend on every platform. Cover real package installation, migration, failure recovery, and legacy database compatibility. Keep authentication storage failures distinct from expired sessions with a pinned Keyv runtime, propagated cache errors, and retryable HTTP 503 responses. Preserve genuine 401 failures and verify legacy cache bytes, initialization safety, and session recovery.
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const test = require('node:test');
|
|
const path = require('node:path');
|
|
const dayjs = require('dayjs');
|
|
const load = require('../helpers/load-security-module.cjs');
|
|
test('subscription becomes idle and closes its log even when completion logging fails', async () => {
|
|
const updates = [];
|
|
let closed = 0;
|
|
let notified = 0;
|
|
const Subscription = load(path.resolve('back/services/subscription.ts'), {
|
|
'../config': {},
|
|
'../data/subscription': {
|
|
SubscriptionModel: {
|
|
nativeUpdate: async (where, values) => {
|
|
return updates.push(values);
|
|
},
|
|
},
|
|
SubscriptionStatus: { idle: 1 },
|
|
},
|
|
'../data/cron': {},
|
|
'../config/util': { handleLogPath: async () => '/tmp/unused-log' },
|
|
'../config/const': { LOG_END_SYMBOL: 'end' },
|
|
'../config/subscription': {},
|
|
'../shared/i18n': { t: (s) => s, tf: (s) => s },
|
|
'../shared/pLimit': {},
|
|
'../shared/logReader': {},
|
|
'../shared/logStreamManager': {
|
|
logStreamManager: {
|
|
write: async () => {
|
|
throw new Error('ENOSPC');
|
|
},
|
|
closeStream: async () => {
|
|
closed++;
|
|
throw new Error('ENOSPC');
|
|
},
|
|
},
|
|
},
|
|
'./schedule': {},
|
|
'./sock': {},
|
|
'./sshKey': {},
|
|
'./cron': {},
|
|
}).default;
|
|
const service = new Subscription(
|
|
{},
|
|
{},
|
|
{ sendMessage: () => notified++ },
|
|
{},
|
|
{},
|
|
);
|
|
service.getDb = async () => ({ id: 1, log_path: 'log' });
|
|
const callbacks = service.taskCallbacks({ id: 1 });
|
|
await assert.rejects(callbacks.onEnd(undefined, dayjs(), 1), /ENOSPC/);
|
|
assert.equal(closed, 1);
|
|
assert.equal(updates.at(-1).status, 1);
|
|
assert.equal(notified, 1);
|
|
});
|