Skip to content

Commit

Permalink
test: add separate termination for proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jun 15, 2024
1 parent dcf30f2 commit 777fa37
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions test/unit/proxy-terminate-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,9 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
global.gc?.()
})

it("should throw if called after termination", async function () {
await proxy.frontEnd.bind(await uniqAddress(proto))
await proxy.backEnd.bind(await uniqAddress(proto))

const sleep_ms = 50

setTimeout(() => proxy.terminate(), sleep_ms)
await proxy.run()

const terminator_test = () => {
try {
await proxy.terminate()
proxy.terminate()
assert.ok(false)
} catch (err) {
if (!isFullError(err)) {
Expand All @@ -44,6 +36,27 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
assert.equal(err.code, "EBADF")
assert.typeOf(err.errno, "number")
}
}

it("should throw if not started yet", async function () {
await proxy.frontEnd.bind(await uniqAddress(proto))
await proxy.backEnd.bind(await uniqAddress(proto))

terminator_test()
})

it("should throw if called after termination", async function () {
await proxy.frontEnd.bind(await uniqAddress(proto))
await proxy.backEnd.bind(await uniqAddress(proto))

setTimeout(() => {
proxy.terminate()
}, 50)

await proxy.run()
// TODO throws Operation not supported

terminator_test()
})
})
}

0 comments on commit 777fa37

Please sign in to comment.