]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/utils/server/servers.ts
Add test regarding tmp directory
[github/Chocobozzz/PeerTube.git] / shared / utils / server / servers.ts
index 88d2b390cf9015bf9d83cd3b232f8c79bcfc2f38..568385a419b13ef01c9db9aa45fc3912137c987a 100644 (file)
@@ -1,7 +1,11 @@
+/* tslint:disable:no-unused-expression */
+
 import { ChildProcess, exec, fork } from 'child_process'
 import { join } from 'path'
 import { root, wait } from '../miscs/miscs'
-import { readFile } from 'fs-extra'
+import { readdir, readFile } from 'fs-extra'
+import { existsSync } from 'fs'
+import { expect } from 'chai'
 
 interface ServerInfo {
   app: ChildProcess,
@@ -153,6 +157,18 @@ async function reRunServer (server: ServerInfo, configOverride?: any) {
   return server
 }
 
+async function checkTmpIsEmpty (server: ServerInfo) {
+  const testDirectory = 'test' + server.serverNumber
+
+  const directoryPath = join(root(), testDirectory, 'tmp')
+
+  const directoryExists = existsSync(directoryPath)
+  expect(directoryExists).to.be.true
+
+  const files = await readdir(directoryPath)
+  expect(files).to.have.lengthOf(0)
+}
+
 function killallServers (servers: ServerInfo[]) {
   for (const server of servers) {
     process.kill(-server.app.pid)
@@ -175,6 +191,7 @@ async function waitUntilLog (server: ServerInfo, str: string, count = 1) {
 // ---------------------------------------------------------------------------
 
 export {
+  checkTmpIsEmpty,
   ServerInfo,
   flushAndRunMultipleServers,
   flushTests,