diff options
author | Chocobozzz <me@florianbigard.com> | 2021-09-06 08:13:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-09-06 08:13:11 +0200 |
commit | 70430c2796b6c0455a863edc62760a3d45951fc5 (patch) | |
tree | 7620d5a8db0c9b6cbf5a11d1c794875402828789 /shared/extra-utils/mock-servers/utils.ts | |
parent | 6d210220be0875d63461829d83c6e3a59d05cf7a (diff) | |
download | PeerTube-70430c2796b6c0455a863edc62760a3d45951fc5.tar.gz PeerTube-70430c2796b6c0455a863edc62760a3d45951fc5.tar.zst PeerTube-70430c2796b6c0455a863edc62760a3d45951fc5.zip |
Wait mock server termination
Diffstat (limited to 'shared/extra-utils/mock-servers/utils.ts')
-rw-r--r-- | shared/extra-utils/mock-servers/utils.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/shared/extra-utils/mock-servers/utils.ts b/shared/extra-utils/mock-servers/utils.ts new file mode 100644 index 000000000..64d94c868 --- /dev/null +++ b/shared/extra-utils/mock-servers/utils.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | import { Server } from 'http' | ||
2 | |||
3 | function terminateServer (server: Server) { | ||
4 | if (!server) return Promise.resolve() | ||
5 | |||
6 | return new Promise<void>((res, rej) => { | ||
7 | server.close(err => { | ||
8 | if (err) return rej(err) | ||
9 | |||
10 | return res() | ||
11 | }) | ||
12 | }) | ||
13 | } | ||
14 | |||
15 | export { | ||
16 | terminateServer | ||
17 | } | ||