mirror of https://github.com/Chocobozzz/PeerTube
Add test regarding tmp directory
parent
9f8ca79284
commit
8923187455
|
@ -8,6 +8,7 @@ import { VideoPrivacy } from '../../../../shared/models/videos'
|
||||||
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
|
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
|
||||||
import {
|
import {
|
||||||
addVideoChannel,
|
addVideoChannel,
|
||||||
|
checkTmpIsEmpty,
|
||||||
checkVideoFilesWereRemoved,
|
checkVideoFilesWereRemoved,
|
||||||
completeVideoCheck,
|
completeVideoCheck,
|
||||||
createUser,
|
createUser,
|
||||||
|
@ -1008,6 +1009,14 @@ describe('Test multiple servers', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('TMP directory', function () {
|
||||||
|
it('Should have an empty tmp directory', async function () {
|
||||||
|
for (const server of servers) {
|
||||||
|
await checkTmpIsEmpty(server)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
killallServers(servers)
|
killallServers(servers)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
/* tslint:disable:no-unused-expression */
|
||||||
|
|
||||||
import { ChildProcess, exec, fork } from 'child_process'
|
import { ChildProcess, exec, fork } from 'child_process'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { root, wait } from '../miscs/miscs'
|
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 {
|
interface ServerInfo {
|
||||||
app: ChildProcess,
|
app: ChildProcess,
|
||||||
|
@ -153,6 +157,18 @@ async function reRunServer (server: ServerInfo, configOverride?: any) {
|
||||||
return server
|
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[]) {
|
function killallServers (servers: ServerInfo[]) {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
process.kill(-server.app.pid)
|
process.kill(-server.app.pid)
|
||||||
|
@ -175,6 +191,7 @@ async function waitUntilLog (server: ServerInfo, str: string, count = 1) {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
checkTmpIsEmpty,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
flushTests,
|
flushTests,
|
||||||
|
|
|
@ -271,7 +271,7 @@ function removeVideo (url: string, token: string, id: number | string, expectedS
|
||||||
async function checkVideoFilesWereRemoved (
|
async function checkVideoFilesWereRemoved (
|
||||||
videoUUID: string,
|
videoUUID: string,
|
||||||
serverNumber: number,
|
serverNumber: number,
|
||||||
directories = [ 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ]
|
directories = [ 'redundancy', 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ]
|
||||||
) {
|
) {
|
||||||
const testDirectory = 'test' + serverNumber
|
const testDirectory = 'test' + serverNumber
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue