diff options
Diffstat (limited to 'server/tests/shared/actors.ts')
-rw-r--r-- | server/tests/shared/actors.ts | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/server/tests/shared/actors.ts b/server/tests/shared/actors.ts deleted file mode 100644 index 41fd72e89..000000000 --- a/server/tests/shared/actors.ts +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
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' | ||
5 | import { Account, VideoChannel } from '@shared/models' | ||
6 | import { PeerTubeServer } from '@shared/server-commands' | ||
7 | |||
8 | async function expectChannelsFollows (options: { | ||
9 | server: PeerTubeServer | ||
10 | handle: string | ||
11 | followers: number | ||
12 | following: number | ||
13 | }) { | ||
14 | const { server } = options | ||
15 | const { data } = await server.channels.list() | ||
16 | |||
17 | return expectActorFollow({ ...options, data }) | ||
18 | } | ||
19 | |||
20 | async function expectAccountFollows (options: { | ||
21 | server: PeerTubeServer | ||
22 | handle: string | ||
23 | followers: number | ||
24 | following: number | ||
25 | }) { | ||
26 | const { server } = options | ||
27 | const { data } = await server.accounts.list() | ||
28 | |||
29 | return expectActorFollow({ ...options, data }) | ||
30 | } | ||
31 | |||
32 | async function checkActorFilesWereRemoved (filename: string, server: PeerTubeServer) { | ||
33 | for (const directory of [ 'avatars' ]) { | ||
34 | const directoryPath = server.getDirectoryPath(directory) | ||
35 | |||
36 | const directoryExists = await pathExists(directoryPath) | ||
37 | expect(directoryExists).to.be.true | ||
38 | |||
39 | const files = await readdir(directoryPath) | ||
40 | for (const file of files) { | ||
41 | expect(file).to.not.contain(filename) | ||
42 | } | ||
43 | } | ||
44 | } | ||
45 | |||
46 | export { | ||
47 | expectAccountFollows, | ||
48 | expectChannelsFollows, | ||
49 | checkActorFilesWereRemoved | ||
50 | } | ||
51 | |||
52 | // --------------------------------------------------------------------------- | ||
53 | |||
54 | function expectActorFollow (options: { | ||
55 | server: PeerTubeServer | ||
56 | data: (Account | VideoChannel)[] | ||
57 | handle: string | ||
58 | followers: number | ||
59 | following: number | ||
60 | }) { | ||
61 | const { server, data, handle, followers, following } = options | ||
62 | |||
63 | const actor = data.find(a => a.name + '@' + a.host === handle) | ||
64 | const message = `${handle} on ${server.url}` | ||
65 | |||
66 | expect(actor, message).to.exist | ||
67 | expect(actor.followersCount).to.equal(followers, message) | ||
68 | expect(actor.followingCount).to.equal(following, message) | ||
69 | } | ||