diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-08-26 05:12:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-26 08:42:11 +0530 |
commit | da10c9c8d1f7bf6ada71bb70f5f331ed830e5b0e (patch) | |
tree | 1f8e0456e8461f7c66d444e7f8bebcb914bb34a0 /cli/tests | |
parent | 376665d1154501660e7b20f760a0482509cff8b0 (diff) |
fix(ext/flash): panic on AddrInUse (#15607)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/flash_test.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts index 07be6dfcc..fef45beb9 100644 --- a/cli/tests/unit/flash_test.ts +++ b/cli/tests/unit/flash_test.ts @@ -57,6 +57,35 @@ Deno.test(async function httpServerCanResolveHostnames() { await server; }); +Deno.test(async function httpServerRejectsOnAddrInUse() { + const ac = new AbortController(); + const listeningPromise = deferred(); + + const server = Deno.serve({ + handler: (_req) => new Response("ok"), + hostname: "localhost", + port: 4501, + signal: ac.signal, + onListen: onListen(listeningPromise), + onError: createOnErrorCb(ac), + }); + + assertRejects( + () => + Deno.serve({ + handler: (_req) => new Response("ok"), + hostname: "localhost", + port: 4501, + signal: ac.signal, + onListen: onListen(listeningPromise), + onError: createOnErrorCb(ac), + }), + Deno.errors.AddrInUse, + ); + ac.abort(); + await server; +}); + Deno.test({ permissions: { net: true } }, async function httpServerBasic() { const ac = new AbortController(); const promise = deferred(); |