lint
This commit is contained in:
977 files changed
+198426
-158324
No files matched your search
@@ -2,34 +2,31 @@ 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';
|
||||
import { listPerUinOneBotConfigFiles, readBackupConfigFile } from '../src/webui/server';
|
||||
|
||||
describe('backup filesystem adapter', () => {
|
||||
let root: string;
|
||||
let root: string;
|
||||
|
||||
beforeEach(() => {
|
||||
root = fs.mkdtempSync(path.join(os.tmpdir(), 'snowluma-backup-http-'));
|
||||
});
|
||||
beforeEach(() => {
|
||||
root = fs.mkdtempSync(path.join(os.tmpdir(), 'snowluma-backup-http-'));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fs.rmSync(root, { recursive: true, force: true });
|
||||
});
|
||||
afterEach(() => {
|
||||
fs.rmSync(root, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it('treats only a missing file as absent', () => {
|
||||
expect(readBackupConfigFile(root, 'missing.json')).toBeNull();
|
||||
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();
|
||||
});
|
||||
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([]);
|
||||
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();
|
||||
});
|
||||
const notDirectory = path.join(root, 'not-a-directory');
|
||||
fs.writeFileSync(notDirectory, 'x');
|
||||
expect(() => listPerUinOneBotConfigFiles(notDirectory)).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user