MCPcopy
hub / github.com/coder/mux / FakeClientChannel

Class FakeClientChannel

src/node/runtime/transports/SSH2Transport.test.ts:7–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5import { SSH2Transport } from "./SSH2Transport";
6
7class FakeClientChannel extends EventEmitter {
8 readonly stdout = new PassThrough();
9 readonly stderr?: PassThrough;
10 destroyed = false;
11 writableEnded = false;
12
13 constructor(options?: { includeStderr?: boolean }) {
14 super();
15 if (options?.includeStderr) {
16 this.stderr = new PassThrough();
17 }
18 }
19
20 pipe<T extends NodeJS.WritableStream>(destination: T): T {
21 this.stdout.pipe(destination);
22 return destination;
23 }
24
25 write(_chunk: string | Buffer | Uint8Array): boolean {
26 return true;
27 }
28
29 end(): void {
30 this.writableEnded = true;
31 }
32
33 close(): void {
34 this.destroyed = true;
35 this.writableEnded = true;
36 this.stdout.end();
37 this.stderr?.end();
38 }
39
40 signal(_signal: string): void {
41 // No-op for tests.
42 }
43
44 emitStderr(text: string): void {
45 this.stderr?.write(text);
46 }
47
48 finish(exitCode = 0): void {
49 this.emit("exit", exitCode, null);
50 this.close();
51 this.emit("close", exitCode, null);
52 }
53}
54
55function createFakeClient(channel: FakeClientChannel) {
56 return {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected