diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-17 09:29:23 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-17 09:29:23 +0100 |
commit | bf54587a3e2ad9c2c186828f2a5682b91ee2cc00 (patch) | |
tree | 54b40aaf01bae210632473285c3c7571d51e4f89 /shared/extra-utils/users/actors.ts | |
parent | 6b5f72beda96d8b7e4d6329c4001827334de27dd (diff) | |
download | PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.tar.gz PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.tar.zst PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.zip |
shared/ typescript types dir server-commands
Diffstat (limited to 'shared/extra-utils/users/actors.ts')
-rw-r--r-- | shared/extra-utils/users/actors.ts | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/shared/extra-utils/users/actors.ts b/shared/extra-utils/users/actors.ts deleted file mode 100644 index 12c3e078a..000000000 --- a/shared/extra-utils/users/actors.ts +++ /dev/null | |||
@@ -1,73 +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 { join } from 'path' | ||
6 | import { root } from '@shared/core-utils' | ||
7 | import { Account, VideoChannel } from '@shared/models' | ||
8 | import { PeerTubeServer } from '../server' | ||
9 | |||
10 | async function expectChannelsFollows (options: { | ||
11 | server: PeerTubeServer | ||
12 | handle: string | ||
13 | followers: number | ||
14 | following: number | ||
15 | }) { | ||
16 | const { server } = options | ||
17 | const { data } = await server.channels.list() | ||
18 | |||
19 | return expectActorFollow({ ...options, data }) | ||
20 | } | ||
21 | |||
22 | async function expectAccountFollows (options: { | ||
23 | server: PeerTubeServer | ||
24 | handle: string | ||
25 | followers: number | ||
26 | following: number | ||
27 | }) { | ||
28 | const { server } = options | ||
29 | const { data } = await server.accounts.list() | ||
30 | |||
31 | return expectActorFollow({ ...options, data }) | ||
32 | } | ||
33 | |||
34 | async function checkActorFilesWereRemoved (filename: string, serverNumber: number) { | ||
35 | const testDirectory = 'test' + serverNumber | ||
36 | |||
37 | for (const directory of [ 'avatars' ]) { | ||
38 | const directoryPath = join(root(), testDirectory, directory) | ||
39 | |||
40 | const directoryExists = await pathExists(directoryPath) | ||
41 | expect(directoryExists).to.be.true | ||
42 | |||
43 | const files = await readdir(directoryPath) | ||
44 | for (const file of files) { | ||
45 | expect(file).to.not.contain(filename) | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | |||
50 | export { | ||
51 | expectAccountFollows, | ||
52 | expectChannelsFollows, | ||
53 | checkActorFilesWereRemoved | ||
54 | } | ||
55 | |||
56 | // --------------------------------------------------------------------------- | ||
57 | |||
58 | function expectActorFollow (options: { | ||
59 | server: PeerTubeServer | ||
60 | data: (Account | VideoChannel)[] | ||
61 | handle: string | ||
62 | followers: number | ||
63 | following: number | ||
64 | }) { | ||
65 | const { server, data, handle, followers, following } = options | ||
66 | |||
67 | const actor = data.find(a => a.name + '@' + a.host === handle) | ||
68 | const message = `${handle} on ${server.url}` | ||
69 | |||
70 | expect(actor, message).to.exist | ||
71 | expect(actor.followersCount).to.equal(followers, message) | ||
72 | expect(actor.followingCount).to.equal(following, message) | ||
73 | } | ||