feat: 创建数据库

This commit is contained in:
R524809
2026-10-12 16:56:42 +08:00
parent 3c6fd2c8ca
commit 63a6993276
35 changed files with 826 additions and 266 deletions
+12 -12
View File
@@ -3,25 +3,25 @@ import { test } from 'node:test';
import { getRuntimeOptions } from '../src/common/runtime-options';
test('使用本地默认 host 和 port', () => {
assert.deepEqual(getRuntimeOptions({}), {
host: '127.0.0.1',
port: 3000,
});
assert.deepEqual(getRuntimeOptions({}), {
host: '127.0.0.1',
port: 3000,
});
});
test('读取显式 host 和 port', () => {
assert.deepEqual(getRuntimeOptions({ HOST: '0.0.0.0', PORT: '4000' }), {
host: '0.0.0.0',
port: 4000,
});
assert.deepEqual(getRuntimeOptions({ HOST: '0.0.0.0', PORT: '4000' }), {
host: '0.0.0.0',
port: 4000,
});
});
test('拒绝非法端口', () => {
for (const port of ['', '0', '65536', '-1', '3000abc', '3.5', '1e3']) {
assert.throws(() => getRuntimeOptions({ PORT: port }), /PORT/);
}
for (const port of ['', '0', '65536', '-1', '3000abc', '3.5', '1e3']) {
assert.throws(() => getRuntimeOptions({ PORT: port }), /PORT/);
}
});
test('拒绝空 host', () => {
assert.throws(() => getRuntimeOptions({ HOST: ' ' }), /HOST/);
assert.throws(() => getRuntimeOptions({ HOST: ' ' }), /HOST/);
});