diff options
Diffstat (limited to 'server/tests/shared/directories.ts')
-rw-r--r-- | server/tests/shared/directories.ts | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/server/tests/shared/directories.ts b/server/tests/shared/directories.ts index a614cef7c..4f4282554 100644 --- a/server/tests/shared/directories.ts +++ b/server/tests/shared/directories.ts | |||
@@ -2,9 +2,11 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { homedir } from 'os' | ||
6 | import { join } from 'path' | ||
5 | import { PeerTubeServer } from '@shared/server-commands' | 7 | import { PeerTubeServer } from '@shared/server-commands' |
6 | 8 | ||
7 | async function checkTmpIsEmpty (server: PeerTubeServer) { | 9 | export async function checkTmpIsEmpty (server: PeerTubeServer) { |
8 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) | 10 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) |
9 | 11 | ||
10 | if (await pathExists(server.getDirectoryPath('tmp/hls'))) { | 12 | if (await pathExists(server.getDirectoryPath('tmp/hls'))) { |
@@ -12,11 +14,11 @@ async function checkTmpIsEmpty (server: PeerTubeServer) { | |||
12 | } | 14 | } |
13 | } | 15 | } |
14 | 16 | ||
15 | async function checkPersistentTmpIsEmpty (server: PeerTubeServer) { | 17 | export async function checkPersistentTmpIsEmpty (server: PeerTubeServer) { |
16 | await checkDirectoryIsEmpty(server, 'tmp-persistent') | 18 | await checkDirectoryIsEmpty(server, 'tmp-persistent') |
17 | } | 19 | } |
18 | 20 | ||
19 | async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { | 21 | export async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { |
20 | const directoryPath = server.getDirectoryPath(directory) | 22 | const directoryPath = server.getDirectoryPath(directory) |
21 | 23 | ||
22 | const directoryExists = await pathExists(directoryPath) | 24 | const directoryExists = await pathExists(directoryPath) |
@@ -28,8 +30,13 @@ async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, | |||
28 | expect(filtered).to.have.lengthOf(0) | 30 | expect(filtered).to.have.lengthOf(0) |
29 | } | 31 | } |
30 | 32 | ||
31 | export { | 33 | export async function checkPeerTubeRunnerCacheIsEmpty () { |
32 | checkTmpIsEmpty, | 34 | const directoryPath = join(homedir(), '.cache', 'peertube-runner-nodejs', 'test', 'transcoding') |
33 | checkPersistentTmpIsEmpty, | 35 | |
34 | checkDirectoryIsEmpty | 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) | ||
35 | } | 42 | } |