aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-12-11 09:16:41 +0100
committerChocobozzz <me@florianbigard.com>2018-12-11 09:18:02 +0100
commit8923187455c5aa7167d813c5c745d3857f183fd7 (patch)
treeb1419f01b100f84edc851bd17a728d88e878341b /shared/utils/server
parent9f8ca79284f93693c734dd4b9a27b471017fc441 (diff)
downloadPeerTube-8923187455c5aa7167d813c5c745d3857f183fd7.tar.gz
PeerTube-8923187455c5aa7167d813c5c745d3857f183fd7.tar.zst
PeerTube-8923187455c5aa7167d813c5c745d3857f183fd7.zip
Add test regarding tmp directory
Diffstat (limited to 'shared/utils/server')
-rw-r--r--shared/utils/server/servers.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/shared/utils/server/servers.ts b/shared/utils/server/servers.ts
index 88d2b390c..568385a41 100644
--- a/shared/utils/server/servers.ts
+++ b/shared/utils/server/servers.ts
@@ -1,7 +1,11 @@
1/* tslint:disable:no-unused-expression */
2
1import { ChildProcess, exec, fork } from 'child_process' 3import { ChildProcess, exec, fork } from 'child_process'
2import { join } from 'path' 4import { join } from 'path'
3import { root, wait } from '../miscs/miscs' 5import { root, wait } from '../miscs/miscs'
4import { readFile } from 'fs-extra' 6import { readdir, readFile } from 'fs-extra'
7import { existsSync } from 'fs'
8import { expect } from 'chai'
5 9
6interface ServerInfo { 10interface ServerInfo {
7 app: ChildProcess, 11 app: ChildProcess,
@@ -153,6 +157,18 @@ async function reRunServer (server: ServerInfo, configOverride?: any) {
153 return server 157 return server
154} 158}
155 159
160async function checkTmpIsEmpty (server: ServerInfo) {
161 const testDirectory = 'test' + server.serverNumber
162
163 const directoryPath = join(root(), testDirectory, 'tmp')
164
165 const directoryExists = existsSync(directoryPath)
166 expect(directoryExists).to.be.true
167
168 const files = await readdir(directoryPath)
169 expect(files).to.have.lengthOf(0)
170}
171
156function killallServers (servers: ServerInfo[]) { 172function killallServers (servers: ServerInfo[]) {
157 for (const server of servers) { 173 for (const server of servers) {
158 process.kill(-server.app.pid) 174 process.kill(-server.app.pid)
@@ -175,6 +191,7 @@ async function waitUntilLog (server: ServerInfo, str: string, count = 1) {
175// --------------------------------------------------------------------------- 191// ---------------------------------------------------------------------------
176 192
177export { 193export {
194 checkTmpIsEmpty,
178 ServerInfo, 195 ServerInfo,
179 flushAndRunMultipleServers, 196 flushAndRunMultipleServers,
180 flushTests, 197 flushTests,