diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-11 09:16:41 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-12-11 09:18:02 +0100 |
commit | 8923187455c5aa7167d813c5c745d3857f183fd7 (patch) | |
tree | b1419f01b100f84edc851bd17a728d88e878341b /shared/utils/server | |
parent | 9f8ca79284f93693c734dd4b9a27b471017fc441 (diff) | |
download | PeerTube-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.ts | 19 |
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 | |||
1 | import { ChildProcess, exec, fork } from 'child_process' | 3 | import { ChildProcess, exec, fork } from 'child_process' |
2 | import { join } from 'path' | 4 | import { join } from 'path' |
3 | import { root, wait } from '../miscs/miscs' | 5 | import { root, wait } from '../miscs/miscs' |
4 | import { readFile } from 'fs-extra' | 6 | import { readdir, readFile } from 'fs-extra' |
7 | import { existsSync } from 'fs' | ||
8 | import { expect } from 'chai' | ||
5 | 9 | ||
6 | interface ServerInfo { | 10 | interface 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 | ||
160 | async 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 | |||
156 | function killallServers (servers: ServerInfo[]) { | 172 | function 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 | ||
177 | export { | 193 | export { |
194 | checkTmpIsEmpty, | ||
178 | ServerInfo, | 195 | ServerInfo, |
179 | flushAndRunMultipleServers, | 196 | flushAndRunMultipleServers, |
180 | flushTests, | 197 | flushTests, |