feat: release 2.5.1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import {
|
||||
parseLogTailLines,
|
||||
runLogs,
|
||||
type LogApiEvent,
|
||||
type LogEventWriter,
|
||||
@@ -81,4 +82,34 @@ describe("logs API command runner", () => {
|
||||
);
|
||||
expect(receivedSignal).toBe(controller.signal);
|
||||
});
|
||||
|
||||
test.each([false, true])("sends -n with follow=%s", async (follow) => {
|
||||
const paths: string[] = [];
|
||||
const stream: LogsApiStream = async function* (path, _init, options) {
|
||||
paths.push(path);
|
||||
expect(options?.timeoutMs).toBe(follow ? 0 : undefined);
|
||||
yield* [] as never[];
|
||||
};
|
||||
await runLogs("shop", "web", follow, undefined, stream, () => {}, 0);
|
||||
expect(paths).toEqual([
|
||||
`/workspaces/shop/logs?service=web${follow ? "&follow=true" : ""}&tailLines=0`,
|
||||
]);
|
||||
});
|
||||
|
||||
test("accepts only non-negative safe integer line counts", async () => {
|
||||
expect(parseLogTailLines("25")).toBe(25);
|
||||
expect(parseLogTailLines("0")).toBe(0);
|
||||
for (const invalid of ["-1", "1.5", "2abc", "", "1e3", "9007199254740992"])
|
||||
expect(() => parseLogTailLines(invalid)).toThrow("non-negative integer");
|
||||
|
||||
let called = false;
|
||||
const stream: LogsApiStream = async function* () {
|
||||
called = true;
|
||||
yield* [] as never[];
|
||||
};
|
||||
await expect(
|
||||
runLogs("shop", undefined, false, undefined, stream, () => {}, -1),
|
||||
).rejects.toThrow("non-negative integer");
|
||||
expect(called).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user