Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wperron committed Nov 27, 2020
1 parent ff66a24 commit 4754d51
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cli/tests/unit/net_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,44 @@ unitTest(
},
);

unitTest(
{ ignore: Deno.build.os === "windows", perms: { read: true } },
function netUnixListenWritePermission(): void {
try {
const filePath = Deno.makeTempFileSync();
const socket = Deno.listen({
path: filePath,
transport: "unix",
});
assert(socket.addr.transport === "unix");
assertEquals(socket.addr.path, filePath);
socket.close();
} catch (e) {
assert(!!e);
assert(e instanceof Deno.errors.PermissionDenied);
}
},
);

unitTest(
{ ignore: Deno.build.os === "windows", perms: { read: true } },
function netUnixPacketListenWritePermission(): void {
try {
const filePath = Deno.makeTempFileSync();
const socket = Deno.listenDatagram({
path: filePath,
transport: "unixpacket",
});
assert(socket.addr.transport === "unixpacket");
assertEquals(socket.addr.path, filePath);
socket.close();
} catch (e) {
assert(!!e);
assert(e instanceof Deno.errors.PermissionDenied);
}
},
);

unitTest(
{
perms: { net: true },
Expand Down

0 comments on commit 4754d51

Please sign in to comment.