2020-02-27 00:48:35 +09:00
|
|
|
/** Create dummy Deno.Conn object with given base properties */
|
|
|
|
export function mockConn(base: Partial<Deno.Conn> = {}): Deno.Conn {
|
|
|
|
return {
|
|
|
|
localAddr: {
|
|
|
|
transport: "tcp",
|
|
|
|
hostname: "",
|
2020-03-29 04:03:49 +11:00
|
|
|
port: 0,
|
2020-02-27 00:48:35 +09:00
|
|
|
},
|
|
|
|
remoteAddr: {
|
|
|
|
transport: "tcp",
|
|
|
|
hostname: "",
|
2020-03-29 04:03:49 +11:00
|
|
|
port: 0,
|
2020-02-27 00:48:35 +09:00
|
|
|
},
|
|
|
|
rid: -1,
|
|
|
|
closeWrite: (): void => {},
|
2020-04-28 17:40:43 +01:00
|
|
|
read: (): Promise<number | null> => {
|
2020-03-20 14:38:34 +01:00
|
|
|
return Promise.resolve(0);
|
2020-02-27 00:48:35 +09:00
|
|
|
},
|
2020-04-02 15:20:17 -04:00
|
|
|
write: (): Promise<number> => {
|
|
|
|
return Promise.resolve(-1);
|
2020-02-27 00:48:35 +09:00
|
|
|
},
|
|
|
|
close: (): void => {},
|
2020-03-29 04:03:49 +11:00
|
|
|
...base,
|
2020-02-27 00:48:35 +09:00
|
|
|
};
|
|
|
|
}
|