diff options
author | buoyantair <buoyantair@gmail.com> | 2018-10-29 22:18:31 +0530 |
---|---|---|
committer | buoyantair <buoyantair@gmail.com> | 2018-10-29 22:18:31 +0530 |
commit | 9639bd175726b73f8fe664b5ced12a72407b1f0b (patch) | |
tree | 689d4c9e0a1f8dcc55e0ba4e694af3b09bff2cad /server/tests/utils/users/accounts.ts | |
parent | 71607e4a65d3a8904bcd418ab7acbc2f34f725ff (diff) | |
download | PeerTube-9639bd175726b73f8fe664b5ced12a72407b1f0b.tar.gz PeerTube-9639bd175726b73f8fe664b5ced12a72407b1f0b.tar.zst PeerTube-9639bd175726b73f8fe664b5ced12a72407b1f0b.zip |
Move utils to /shared
Move utils used by /server/tools/* & /server/tests/**/* into
/shared folder.
Issue: #1336
Diffstat (limited to 'server/tests/utils/users/accounts.ts')
-rw-r--r-- | server/tests/utils/users/accounts.ts | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/server/tests/utils/users/accounts.ts b/server/tests/utils/users/accounts.ts deleted file mode 100644 index f82b8d906..000000000 --- a/server/tests/utils/users/accounts.ts +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { existsSync, readdir } from 'fs-extra' | ||
5 | import { join } from 'path' | ||
6 | import { Account } from '../../../../shared/models/actors' | ||
7 | import { root } from '../index' | ||
8 | import { makeGetRequest } from '../requests/requests' | ||
9 | |||
10 | function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) { | ||
11 | const path = '/api/v1/accounts' | ||
12 | |||
13 | return makeGetRequest({ | ||
14 | url, | ||
15 | query: { sort }, | ||
16 | path, | ||
17 | statusCodeExpected | ||
18 | }) | ||
19 | } | ||
20 | |||
21 | function getAccount (url: string, accountName: string, statusCodeExpected = 200) { | ||
22 | const path = '/api/v1/accounts/' + accountName | ||
23 | |||
24 | return makeGetRequest({ | ||
25 | url, | ||
26 | path, | ||
27 | statusCodeExpected | ||
28 | }) | ||
29 | } | ||
30 | |||
31 | async function expectAccountFollows (url: string, nameWithDomain: string, followersCount: number, followingCount: number) { | ||
32 | const res = await getAccountsList(url) | ||
33 | const account = res.body.data.find((a: Account) => a.name + '@' + a.host === nameWithDomain) | ||
34 | |||
35 | const message = `${nameWithDomain} on ${url}` | ||
36 | expect(account.followersCount).to.equal(followersCount, message) | ||
37 | expect(account.followingCount).to.equal(followingCount, message) | ||
38 | } | ||
39 | |||
40 | async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: number) { | ||
41 | const testDirectory = 'test' + serverNumber | ||
42 | |||
43 | for (const directory of [ 'avatars' ]) { | ||
44 | const directoryPath = join(root(), testDirectory, directory) | ||
45 | |||
46 | const directoryExists = existsSync(directoryPath) | ||
47 | expect(directoryExists).to.be.true | ||
48 | |||
49 | const files = await readdir(directoryPath) | ||
50 | for (const file of files) { | ||
51 | expect(file).to.not.contain(actorUUID) | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | // --------------------------------------------------------------------------- | ||
57 | |||
58 | export { | ||
59 | getAccount, | ||
60 | expectAccountFollows, | ||
61 | getAccountsList, | ||
62 | checkActorFilesWereRemoved | ||
63 | } | ||