]>
Commit | Line | Data |
---|---|---|
6c5065a0 C |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
3 | import { expect } from 'chai' | |
4 | import { pathExists, readdir } from 'fs-extra' | |
5e47f6ab C |
5 | import { homedir } from 'os' |
6 | import { join } from 'path' | |
c55e3d72 | 7 | import { PeerTubeServer } from '@shared/server-commands' |
6c5065a0 | 8 | |
5e47f6ab | 9 | export async function checkTmpIsEmpty (server: PeerTubeServer) { |
6c5065a0 C |
10 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) |
11 | ||
6c5f0d3a | 12 | if (await pathExists(server.getDirectoryPath('tmp/hls'))) { |
6c5065a0 C |
13 | await checkDirectoryIsEmpty(server, 'tmp/hls') |
14 | } | |
15 | } | |
16 | ||
5e47f6ab | 17 | export async function checkPersistentTmpIsEmpty (server: PeerTubeServer) { |
6a490560 C |
18 | await checkDirectoryIsEmpty(server, 'tmp-persistent') |
19 | } | |
20 | ||
5e47f6ab | 21 | export async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { |
6c5f0d3a | 22 | const directoryPath = server.getDirectoryPath(directory) |
6c5065a0 C |
23 | |
24 | const directoryExists = await pathExists(directoryPath) | |
25 | expect(directoryExists).to.be.true | |
26 | ||
27 | const files = await readdir(directoryPath) | |
28 | const filtered = files.filter(f => exceptions.includes(f) === false) | |
29 | ||
30 | expect(filtered).to.have.lengthOf(0) | |
31 | } | |
32 | ||
5e47f6ab C |
33 | export async function checkPeerTubeRunnerCacheIsEmpty () { |
34 | const directoryPath = join(homedir(), '.cache', 'peertube-runner-nodejs', 'test', 'transcoding') | |
35 | ||
36 | const directoryExists = await pathExists(directoryPath) | |
37 | expect(directoryExists).to.be.true | |
38 | ||
39 | const files = await readdir(directoryPath) | |
40 | ||
41 | expect(files).to.have.lengthOf(0) | |
6c5065a0 | 42 | } |