mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
Release v3.8.42 — full CHANGELOG in CHANGELOG.md. CI: 103 checks green incl. CodeQL (all languages), Semgrep, all 8 unit shards, coverage, Node 24 compat, and integration tests. Full unit suite validated locally: 19437 pass / 0 fail. The 3 red checks are advisory and do not gate main (no required status checks): SonarCloud/SonarQube new-code coverage gate, and PR Test Policy (test-masking detector flagging the legitimate dead-Phind provider removal in #5530 — reviewed, correct). Includes cycle-close reconciliation + repair of inherited base-red tests from #5480/#5527/#5427/#5521 that the PR->release fast-path did not exercise.
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { finalizeReadableStream } from "../../../../src/app/api/v1/relay/chat/completions/streamFinalizer.ts";
|
|
|
|
test("finalizeReadableStream finalizes once after the wrapped stream completes", async () => {
|
|
const finalized: unknown[] = [];
|
|
const stream = finalizeReadableStream(
|
|
new ReadableStream<Uint8Array>({
|
|
start(controller) {
|
|
controller.enqueue(new TextEncoder().encode("hello"));
|
|
controller.close();
|
|
},
|
|
}),
|
|
(error) => finalized.push(error)
|
|
);
|
|
|
|
assert.equal(await new Response(stream).text(), "hello");
|
|
assert.deepEqual(finalized, [undefined]);
|
|
});
|
|
|
|
test("finalizeReadableStream finalizes once when the consumer cancels", async () => {
|
|
const finalized: unknown[] = [];
|
|
let cancelReason: unknown;
|
|
const stream = finalizeReadableStream(
|
|
new ReadableStream<Uint8Array>({
|
|
start(controller) {
|
|
controller.enqueue(new TextEncoder().encode("chunk"));
|
|
},
|
|
cancel(reason) {
|
|
cancelReason = reason;
|
|
},
|
|
}),
|
|
(error) => finalized.push(error)
|
|
);
|
|
|
|
const reader = stream.getReader();
|
|
const first = await reader.read();
|
|
assert.equal(new TextDecoder().decode(first.value), "chunk");
|
|
|
|
await reader.cancel("client disconnected");
|
|
await reader.cancel("second cancel");
|
|
|
|
assert.equal(cancelReason, "client disconnected");
|
|
assert.deepEqual(finalized, ["client disconnected"]);
|
|
});
|