refactor(cli): keep relay stream helpers test-local · openclaw/openclaw@a93fc87
vincentkoc
·
2026-06-19
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Native hook relay CLI tests cover relay command registration and runtime delegation. |
2 | | -import { PassThrough } from "node:stream"; |
| 2 | +import { PassThrough, Readable, Writable } from "node:stream"; |
3 | 3 | import { describe, expect, it, vi } from "vitest"; |
4 | | -import { |
5 | | -createReadableTextStream, |
6 | | -createWritableTextBuffer, |
7 | | -runNativeHookRelayCli, |
8 | | -} from "./native-hook-relay-cli.js"; |
| 4 | +import { runNativeHookRelayCli } from "./native-hook-relay-cli.js"; |
| 5 | + |
| 6 | +function createReadableTextStream(text: string): NodeJS.ReadableStream { |
| 7 | +return Readable.from([text]); |
| 8 | +} |
| 9 | + |
| 10 | +function createWritableTextBuffer(): NodeJS.WritableStream & { text: () => string } { |
| 11 | +const chunks: Buffer[] = []; |
| 12 | +const stream = new Writable({ |
| 13 | +write(chunk, _encoding, callback) { |
| 14 | +chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk))); |
| 15 | +callback(); |
| 16 | +}, |
| 17 | +}); |
| 18 | +return Object.assign(stream, { |
| 19 | +text: () => Buffer.concat(chunks).toString("utf8"), |
| 20 | +}); |
| 21 | +} |
9 | 22 | |
10 | 23 | describe("native hook relay CLI", () => { |
11 | 24 | it("reads Codex hook JSON from stdin and forwards it to the gateway relay", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。