diff options
author | William Perron <hey@wperron.io> | 2020-11-27 15:02:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-27 21:02:25 +0100 |
commit | a16adca06b60141c04078a496ac48581bf755e4a (patch) | |
tree | 1937aa128d9351997a4a887bc5b0613597b14ab1 | |
parent | e2858d0bbb13dae202e7da9ee7bbb81916349d1e (diff) |
test(cli): fix brittle network permission test (#8526)
-rw-r--r-- | cli/tests/unit/net_test.ts | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/cli/tests/unit/net_test.ts b/cli/tests/unit/net_test.ts index 890a1bb62..abbb23b33 100644 --- a/cli/tests/unit/net_test.ts +++ b/cli/tests/unit/net_test.ts @@ -68,7 +68,7 @@ unitTest( unitTest( { ignore: Deno.build.os === "windows", perms: { read: true } }, function netUnixListenWritePermission(): void { - try { + assertThrows(() => { const filePath = Deno.makeTempFileSync(); const socket = Deno.listen({ path: filePath, @@ -77,17 +77,14 @@ unitTest( assert(socket.addr.transport === "unix"); assertEquals(socket.addr.path, filePath); socket.close(); - } catch (e) { - assert(!!e); - assert(e instanceof Deno.errors.PermissionDenied); - } + }, Deno.errors.PermissionDenied); }, ); unitTest( { ignore: Deno.build.os === "windows", perms: { read: true } }, function netUnixPacketListenWritePermission(): void { - try { + assertThrows(() => { const filePath = Deno.makeTempFileSync(); const socket = Deno.listenDatagram({ path: filePath, @@ -96,10 +93,7 @@ unitTest( assert(socket.addr.transport === "unixpacket"); assertEquals(socket.addr.path, filePath); socket.close(); - } catch (e) { - assert(!!e); - assert(e instanceof Deno.errors.PermissionDenied); - } + }, Deno.errors.PermissionDenied); }, ); |