Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { listPerUinOneBotConfigFiles, readBackupConfigFile } from '../src/webui/server';
|
|
|
|
describe('backup filesystem adapter', () => {
|
|
let root: string;
|
|
|
|
beforeEach(() => {
|
|
root = fs.mkdtempSync(path.join(os.tmpdir(), 'snowluma-backup-http-'));
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(root, { recursive: true, force: true });
|
|
});
|
|
|
|
it('treats only a missing file as absent', () => {
|
|
expect(readBackupConfigFile(root, 'missing.json')).toBeNull();
|
|
|
|
fs.mkdirSync(path.join(root, 'runtime.json'));
|
|
expect(() => readBackupConfigFile(root, 'runtime.json')).toThrow();
|
|
});
|
|
|
|
it('treats only a missing config directory as an empty OneBot list', () => {
|
|
expect(listPerUinOneBotConfigFiles(path.join(root, 'missing'))).toEqual([]);
|
|
|
|
const notDirectory = path.join(root, 'not-a-directory');
|
|
fs.writeFileSync(notDirectory, 'x');
|
|
expect(() => listPerUinOneBotConfigFiles(notDirectory)).toThrow();
|
|
});
|
|
});
|