refactor(std/http): move io functions to http/io.ts (#4126)

This commit is contained in:
Yusuke Sakurai 2020-02-27 00:48:35 +09:00 committed by GitHub
parent 9a8d6fbd98
commit 942e67c00b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 667 additions and 691 deletions

26
std/http/mock.ts Normal file
View file

@ -0,0 +1,26 @@
/** Create dummy Deno.Conn object with given base properties */
export function mockConn(base: Partial<Deno.Conn> = {}): Deno.Conn {
return {
localAddr: {
transport: "tcp",
hostname: "",
port: 0
},
remoteAddr: {
transport: "tcp",
hostname: "",
port: 0
},
rid: -1,
closeRead: (): void => {},
closeWrite: (): void => {},
read: async (): Promise<number | Deno.EOF> => {
return 0;
},
write: async (): Promise<number> => {
return -1;
},
close: (): void => {},
...base
};
}