45bfae6e94
Initial import of all source code, config, and README assets: the packages workspace (cli, core, server, web, docs, landing, skills), build scripts, tooling config, and CI workflows. Includes the data-layout revision made on this branch: the local data root defaults to ~/.penguin/data (PENGUIN_HOME still overrides; the installer keeps its binaries in ~/.penguin), and every Agent lives under <project>/agents/<agent>/ — path helpers, the three agent-enumeration scans, the system prompt, built-in Skills, tests and docs all follow the new layout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ihk8iQuo3kv2aPjAYEPuR
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
/**
|
||
* resolveServerConfig PORT parsing tests: both the default (missing) and empty string
|
||
* (the common `PORT=` empty value in `.env`) fall back to 7364 — Number("") === 0 used
|
||
* to make the empty string pass range validation and bind to a random port; explicit
|
||
* "0" is preserved (explicit semantics for a random available port); invalid values
|
||
* throw. This matches the CLI's resolvePort semantics (packages/cli serve).
|
||
*/
|
||
import { describe, expect, it } from "vitest";
|
||
import { resolveServerConfig } from "../src/config.js";
|
||
|
||
const base = { PENGUIN_HOME: "/tmp/penguin-config-test" };
|
||
|
||
describe("resolveServerConfig:PORT 解析", () => {
|
||
it("缺省 7364;空串视为未设置(不落到端口 0)", () => {
|
||
expect(resolveServerConfig({ ...base }).port).toBe(7364);
|
||
expect(resolveServerConfig({ ...base, PORT: "" }).port).toBe(7364);
|
||
});
|
||
|
||
it('显式数值生效;显式 "0" 保留(绑随机可用端口)', () => {
|
||
expect(resolveServerConfig({ ...base, PORT: "8930" }).port).toBe(8930);
|
||
expect(resolveServerConfig({ ...base, PORT: "0" }).port).toBe(0);
|
||
});
|
||
|
||
it("非整数或超界抛错", () => {
|
||
for (const bad of ["abc", "3.14", "-1", "65536"]) {
|
||
expect(() => resolveServerConfig({ ...base, PORT: bad }), bad).toThrow(/非法端口/);
|
||
}
|
||
});
|
||
});
|