import { ChildProcess, exec, fork } from 'child_process'
import { join } from 'path'
import { root, wait } from '../miscs/miscs'
-import { copy, readdir, readFile, remove } from 'fs-extra'
+import { copy, pathExists, readdir, readFile, remove } from 'fs-extra'
import { existsSync } from 'fs'
import { expect } from 'chai'
import { VideoChannel } from '../../models/videos'
thumbnails: `test${server.internalServerNumber}/thumbnails/`,
torrents: `test${server.internalServerNumber}/torrents/`,
captions: `test${server.internalServerNumber}/captions/`,
- cache: `test${server.internalServerNumber}/cache/`
+ cache: `test${server.internalServerNumber}/cache/`,
+ plugins: `test${server.internalServerNumber}/plugins/`
},
admin: {
email: `admin${server.internalServerNumber}@example.com`
return server
}
-async function checkTmpIsEmpty (server: ServerInfo) {
- return checkDirectoryIsEmpty(server, 'tmp')
+function checkTmpIsEmpty (server: ServerInfo) {
+ return checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css' ])
}
-async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) {
- const testDirectory = 'test' + server.serverNumber
+async function checkDirectoryIsEmpty (server: ServerInfo, directory: string, exceptions: string[] = []) {
+ const testDirectory = 'test' + server.internalServerNumber
const directoryPath = join(root(), testDirectory, directory)
- const directoryExists = existsSync(directoryPath)
+ const directoryExists = await pathExists(directoryPath)
expect(directoryExists).to.be.true
const files = await readdir(directoryPath)
- expect(files).to.have.lengthOf(0)
+ const filtered = files.filter(f => exceptions.includes(f) === false)
+
+ expect(filtered).to.have.lengthOf(0)
}
function killallServers (servers: ServerInfo[]) {
}
async function waitUntilLog (server: ServerInfo, str: string, count = 1) {
- const logfile = join(root(), 'test' + server.serverNumber, 'logs/peertube.log')
+ const logfile = join(root(), 'test' + server.internalServerNumber, 'logs/peertube.log')
while (true) {
const buf = await readFile(logfile)