diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-04-28 21:46:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 21:46:39 +0200 |
commit | 1b6181e434422d3fe5aa49f59f1e7adc4ec4ce8f (patch) | |
tree | 6c58cc861c5efbbfcd51bb92e5a71d1db4ecf4ad /cli/js/tests/net_test.ts | |
parent | ea28a088a473083cb759a3264235005a25450cbc (diff) |
refactor: factor out datagram from Deno.listen(), make it unstable (#4968)
This commit changes Deno.listen() API by factoring out datagram listeners to Deno.listenDatagram(). New Deno.listenDatagram() is unstable.
Diffstat (limited to 'cli/js/tests/net_test.ts')
-rw-r--r-- | cli/js/tests/net_test.ts | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/cli/js/tests/net_test.ts b/cli/js/tests/net_test.ts index fc1802792..f5c1f7abd 100644 --- a/cli/js/tests/net_test.ts +++ b/cli/js/tests/net_test.ts @@ -21,7 +21,7 @@ unitTest( ignore: Deno.build.os === "windows", }, function netUdpListenClose(): void { - const socket = Deno.listen({ + const socket = Deno.listenDatagram({ hostname: "127.0.0.1", port: 4500, transport: "udp", @@ -51,7 +51,7 @@ unitTest( { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, function netUnixPacketListenClose(): void { const filePath = Deno.makeTempFileSync(); - const socket = Deno.listen({ + const socket = Deno.listenDatagram({ path: filePath, transport: "unixpacket", }); @@ -227,12 +227,12 @@ unitTest( unitTest( { ignore: Deno.build.os === "windows", perms: { net: true } }, async function netUdpSendReceive(): Promise<void> { - const alice = Deno.listen({ port: 4500, transport: "udp" }); + const alice = Deno.listenDatagram({ port: 4500, transport: "udp" }); assert(alice.addr.transport === "udp"); assertEquals(alice.addr.port, 4500); assertEquals(alice.addr.hostname, "127.0.0.1"); - const bob = Deno.listen({ port: 4501, transport: "udp" }); + const bob = Deno.listenDatagram({ port: 4501, transport: "udp" }); assert(bob.addr.transport === "udp"); assertEquals(bob.addr.port, 4501); assertEquals(bob.addr.hostname, "127.0.0.1"); @@ -256,11 +256,17 @@ unitTest( { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, async function netUnixPacketSendReceive(): Promise<void> { const filePath = await Deno.makeTempFile(); - const alice = Deno.listen({ path: filePath, transport: "unixpacket" }); + const alice = Deno.listenDatagram({ + path: filePath, + transport: "unixpacket", + }); assert(alice.addr.transport === "unixpacket"); assertEquals(alice.addr.path, filePath); - const bob = Deno.listen({ path: filePath, transport: "unixpacket" }); + const bob = Deno.listenDatagram({ + path: filePath, + transport: "unixpacket", + }); assert(bob.addr.transport === "unixpacket"); assertEquals(bob.addr.path, filePath); @@ -295,7 +301,7 @@ unitTest( unitTest( { ignore: Deno.build.os === "windows", perms: { net: true } }, async function netUdpListenCloseWhileIterating(): Promise<void> { - const socket = Deno.listen({ port: 8000, transport: "udp" }); + const socket = Deno.listenDatagram({ port: 8000, transport: "udp" }); const nextWhileClosing = socket[Symbol.asyncIterator]().next(); socket.close(); assertEquals(await nextWhileClosing, { value: undefined, done: true }); @@ -323,7 +329,10 @@ unitTest( { ignore: Deno.build.os === "windows", perms: { read: true, write: true } }, async function netUnixPacketListenCloseWhileIterating(): Promise<void> { const filePath = Deno.makeTempFileSync(); - const socket = Deno.listen({ path: filePath, transport: "unixpacket" }); + const socket = Deno.listenDatagram({ + path: filePath, + transport: "unixpacket", + }); const nextWhileClosing = socket[Symbol.asyncIterator]().next(); socket.close(); assertEquals(await nextWhileClosing, { value: undefined, done: true }); |