diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-13 09:43:59 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 6c5065a011b099618681a37bd77eaa7bd3db752e (patch) | |
tree | 352252a00b25013c4b1902f6bcd9668aba295c7b /server/tests/cli/prune-storage.ts | |
parent | 0d8ecb7592577f54012413a2b5a9b159cfc90399 (diff) | |
download | PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.gz PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.zst PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.zip |
Introduce server commands
Diffstat (limited to 'server/tests/cli/prune-storage.ts')
-rw-r--r-- | server/tests/cli/prune-storage.ts | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index d4dbee682..68a59a41d 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts | |||
@@ -7,7 +7,6 @@ import { join } from 'path' | |||
7 | import { buildUUID } from '@server/helpers/uuid' | 7 | import { buildUUID } from '@server/helpers/uuid' |
8 | import { HttpStatusCode } from '@shared/core-utils' | 8 | import { HttpStatusCode } from '@shared/core-utils' |
9 | import { | 9 | import { |
10 | buildServerDirectory, | ||
11 | cleanupTests, | 10 | cleanupTests, |
12 | CLICommand, | 11 | CLICommand, |
13 | doubleFollow, | 12 | doubleFollow, |
@@ -26,14 +25,14 @@ import { VideoPlaylistPrivacy } from '@shared/models' | |||
26 | 25 | ||
27 | const expect = chai.expect | 26 | const expect = chai.expect |
28 | 27 | ||
29 | async function countFiles (internalServerNumber: number, directory: string) { | 28 | async function countFiles (server: ServerInfo, directory: string) { |
30 | const files = await readdir(buildServerDirectory({ internalServerNumber }, directory)) | 29 | const files = await readdir(server.serversCommand.buildDirectory(directory)) |
31 | 30 | ||
32 | return files.length | 31 | return files.length |
33 | } | 32 | } |
34 | 33 | ||
35 | async function assertNotExists (internalServerNumber: number, directory: string, substring: string) { | 34 | async function assertNotExists (server: ServerInfo, directory: string, substring: string) { |
36 | const files = await readdir(buildServerDirectory({ internalServerNumber }, directory)) | 35 | const files = await readdir(server.serversCommand.buildDirectory(directory)) |
37 | 36 | ||
38 | for (const f of files) { | 37 | for (const f of files) { |
39 | expect(f).to.not.contain(substring) | 38 | expect(f).to.not.contain(substring) |
@@ -42,19 +41,19 @@ async function assertNotExists (internalServerNumber: number, directory: string, | |||
42 | 41 | ||
43 | async function assertCountAreOkay (servers: ServerInfo[]) { | 42 | async function assertCountAreOkay (servers: ServerInfo[]) { |
44 | for (const server of servers) { | 43 | for (const server of servers) { |
45 | const videosCount = await countFiles(server.internalServerNumber, 'videos') | 44 | const videosCount = await countFiles(server, 'videos') |
46 | expect(videosCount).to.equal(8) | 45 | expect(videosCount).to.equal(8) |
47 | 46 | ||
48 | const torrentsCount = await countFiles(server.internalServerNumber, 'torrents') | 47 | const torrentsCount = await countFiles(server, 'torrents') |
49 | expect(torrentsCount).to.equal(16) | 48 | expect(torrentsCount).to.equal(16) |
50 | 49 | ||
51 | const previewsCount = await countFiles(server.internalServerNumber, 'previews') | 50 | const previewsCount = await countFiles(server, 'previews') |
52 | expect(previewsCount).to.equal(2) | 51 | expect(previewsCount).to.equal(2) |
53 | 52 | ||
54 | const thumbnailsCount = await countFiles(server.internalServerNumber, 'thumbnails') | 53 | const thumbnailsCount = await countFiles(server, 'thumbnails') |
55 | expect(thumbnailsCount).to.equal(6) | 54 | expect(thumbnailsCount).to.equal(6) |
56 | 55 | ||
57 | const avatarsCount = await countFiles(server.internalServerNumber, 'avatars') | 56 | const avatarsCount = await countFiles(server, 'avatars') |
58 | expect(avatarsCount).to.equal(2) | 57 | expect(avatarsCount).to.equal(2) |
59 | } | 58 | } |
60 | } | 59 | } |
@@ -122,7 +121,7 @@ describe('Test prune storage scripts', function () { | |||
122 | it('Should create some dirty files', async function () { | 121 | it('Should create some dirty files', async function () { |
123 | for (let i = 0; i < 2; i++) { | 122 | for (let i = 0; i < 2; i++) { |
124 | { | 123 | { |
125 | const base = buildServerDirectory(servers[0], 'videos') | 124 | const base = servers[0].serversCommand.buildDirectory('videos') |
126 | 125 | ||
127 | const n1 = buildUUID() + '.mp4' | 126 | const n1 = buildUUID() + '.mp4' |
128 | const n2 = buildUUID() + '.webm' | 127 | const n2 = buildUUID() + '.webm' |
@@ -134,7 +133,7 @@ describe('Test prune storage scripts', function () { | |||
134 | } | 133 | } |
135 | 134 | ||
136 | { | 135 | { |
137 | const base = buildServerDirectory(servers[0], 'torrents') | 136 | const base = servers[0].serversCommand.buildDirectory('torrents') |
138 | 137 | ||
139 | const n1 = buildUUID() + '-240.torrent' | 138 | const n1 = buildUUID() + '-240.torrent' |
140 | const n2 = buildUUID() + '-480.torrent' | 139 | const n2 = buildUUID() + '-480.torrent' |
@@ -146,7 +145,7 @@ describe('Test prune storage scripts', function () { | |||
146 | } | 145 | } |
147 | 146 | ||
148 | { | 147 | { |
149 | const base = buildServerDirectory(servers[0], 'thumbnails') | 148 | const base = servers[0].serversCommand.buildDirectory('thumbnails') |
150 | 149 | ||
151 | const n1 = buildUUID() + '.jpg' | 150 | const n1 = buildUUID() + '.jpg' |
152 | const n2 = buildUUID() + '.jpg' | 151 | const n2 = buildUUID() + '.jpg' |
@@ -158,7 +157,7 @@ describe('Test prune storage scripts', function () { | |||
158 | } | 157 | } |
159 | 158 | ||
160 | { | 159 | { |
161 | const base = buildServerDirectory(servers[0], 'previews') | 160 | const base = servers[0].serversCommand.buildDirectory('previews') |
162 | 161 | ||
163 | const n1 = buildUUID() + '.jpg' | 162 | const n1 = buildUUID() + '.jpg' |
164 | const n2 = buildUUID() + '.jpg' | 163 | const n2 = buildUUID() + '.jpg' |
@@ -170,7 +169,7 @@ describe('Test prune storage scripts', function () { | |||
170 | } | 169 | } |
171 | 170 | ||
172 | { | 171 | { |
173 | const base = buildServerDirectory(servers[0], 'avatars') | 172 | const base = servers[0].serversCommand.buildDirectory('avatars') |
174 | 173 | ||
175 | const n1 = buildUUID() + '.png' | 174 | const n1 = buildUUID() + '.png' |
176 | const n2 = buildUUID() + '.jpg' | 175 | const n2 = buildUUID() + '.jpg' |
@@ -195,7 +194,7 @@ describe('Test prune storage scripts', function () { | |||
195 | 194 | ||
196 | for (const directory of Object.keys(badNames)) { | 195 | for (const directory of Object.keys(badNames)) { |
197 | for (const name of badNames[directory]) { | 196 | for (const name of badNames[directory]) { |
198 | await assertNotExists(servers[0].internalServerNumber, directory, name) | 197 | await assertNotExists(servers[0], directory, name) |
199 | } | 198 | } |
200 | } | 199 | } |
201 | }) | 200 | }) |