From 8923187455c5aa7167d813c5c745d3857f183fd7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Dec 2018 09:16:41 +0100 Subject: Add test regarding tmp directory --- shared/utils/server/servers.ts | 19 ++++++++++++++++++- shared/utils/videos/videos.ts | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'shared') 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 @@ +/* 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, diff --git a/shared/utils/videos/videos.ts b/shared/utils/videos/videos.ts index f5fcc6a8a..0cf6e7c4f 100644 --- a/shared/utils/videos/videos.ts +++ b/shared/utils/videos/videos.ts @@ -271,7 +271,7 @@ function removeVideo (url: string, token: string, id: number | string, expectedS async function checkVideoFilesWereRemoved ( videoUUID: string, serverNumber: number, - directories = [ 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ] + directories = [ 'redundancy', 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ] ) { const testDirectory = 'test' + serverNumber -- cgit v1.2.3