diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-23 10:30:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 240085d0056fd97ac3c7fa8fa4ce9bc32afc4d6e (patch) | |
tree | 99879ddce7d4b2970c263cb045c5057ed07354d4 /server | |
parent | 83e6519ba4ee752dc3148a16c69effbfccb13e6b (diff) | |
download | PeerTube-240085d0056fd97ac3c7fa8fa4ce9bc32afc4d6e.tar.gz PeerTube-240085d0056fd97ac3c7fa8fa4ce9bc32afc4d6e.tar.zst PeerTube-240085d0056fd97ac3c7fa8fa4ce9bc32afc4d6e.zip |
Fix tests
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/search.ts | 5 | ||||
-rw-r--r-- | server/initializers/constants.ts | 2 | ||||
-rw-r--r-- | server/lib/avatar.ts | 3 | ||||
-rw-r--r-- | server/tests/api/check-params/video-imports.ts | 2 | ||||
-rw-r--r-- | server/tests/api/users/users-multiple-servers.ts | 7 | ||||
-rw-r--r-- | server/tests/api/videos/video-nsfw.ts | 6 | ||||
-rw-r--r-- | server/tests/cli/update-host.ts | 4 |
7 files changed, 15 insertions, 14 deletions
diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts index d95e7cac9..f408e7932 100644 --- a/server/controllers/api/search.ts +++ b/server/controllers/api/search.ts | |||
@@ -39,8 +39,9 @@ export { searchRouter } | |||
39 | 39 | ||
40 | function searchVideos (req: express.Request, res: express.Response) { | 40 | function searchVideos (req: express.Request, res: express.Response) { |
41 | const query: VideosSearchQuery = req.query | 41 | const query: VideosSearchQuery = req.query |
42 | if (query.search.startsWith('http://') || query.search.startsWith('https://')) { | 42 | const search = query.search |
43 | return searchVideoUrl(query.search, res) | 43 | if (search && (search.startsWith('http://') || search.startsWith('https://'))) { |
44 | return searchVideoUrl(search, res) | ||
44 | } | 45 | } |
45 | 46 | ||
46 | return searchVideosDB(query, res) | 47 | return searchVideosDB(query, res) |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index cd709cd3f..46b63c5e9 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -112,7 +112,7 @@ const JOB_TTL: { [ id in JobType ]: number } = { | |||
112 | 'email': 60000 * 10 // 10 minutes | 112 | 'email': 60000 * 10 // 10 minutes |
113 | } | 113 | } |
114 | const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job | 114 | const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job |
115 | const CRAWL_REQUEST_CONCURRENCY = 5 // How many requests in parallel to fetch remote data (likes, shares...) | 115 | const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...) |
116 | const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds | 116 | const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds |
117 | const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days | 117 | const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days |
118 | 118 | ||
diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts index 7fdef008c..5cfb81fc7 100644 --- a/server/lib/avatar.ts +++ b/server/lib/avatar.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as uuidv4 from 'uuid' | ||
3 | import { sendUpdateActor } from './activitypub/send' | 2 | import { sendUpdateActor } from './activitypub/send' |
4 | import { AVATARS_SIZE, CONFIG, sequelizeTypescript } from '../initializers' | 3 | import { AVATARS_SIZE, CONFIG, sequelizeTypescript } from '../initializers' |
5 | import { updateActorAvatarInstance } from './activitypub' | 4 | import { updateActorAvatarInstance } from './activitypub' |
@@ -15,7 +14,7 @@ async function updateActorAvatarFile ( | |||
15 | accountOrChannel: AccountModel | VideoChannelModel | 14 | accountOrChannel: AccountModel | VideoChannelModel |
16 | ) { | 15 | ) { |
17 | const extension = extname(avatarPhysicalFile.filename) | 16 | const extension = extname(avatarPhysicalFile.filename) |
18 | const avatarName = uuidv4() + extension | 17 | const avatarName = actor.uuid + extension |
19 | const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName) | 18 | const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName) |
20 | await processImage(avatarPhysicalFile, destination, AVATARS_SIZE) | 19 | await processImage(avatarPhysicalFile, destination, AVATARS_SIZE) |
21 | 20 | ||
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 5975985a1..44645b0e2 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -28,7 +28,6 @@ describe('Test video imports API validator', function () { | |||
28 | let userAccessToken = '' | 28 | let userAccessToken = '' |
29 | let accountName: string | 29 | let accountName: string |
30 | let channelId: number | 30 | let channelId: number |
31 | let channelUUID: string | ||
32 | 31 | ||
33 | // --------------------------------------------------------------- | 32 | // --------------------------------------------------------------- |
34 | 33 | ||
@@ -49,7 +48,6 @@ describe('Test video imports API validator', function () { | |||
49 | { | 48 | { |
50 | const res = await getMyUserInformation(server.url, server.accessToken) | 49 | const res = await getMyUserInformation(server.url, server.accessToken) |
51 | channelId = res.body.videoChannels[ 0 ].id | 50 | channelId = res.body.videoChannels[ 0 ].id |
52 | channelUUID = res.body.videoChannels[ 0 ].uuid | ||
53 | accountName = res.body.account.name + '@' + res.body.account.host | 51 | accountName = res.body.account.name + '@' + res.body.account.host |
54 | } | 52 | } |
55 | }) | 53 | }) |
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 575e04546..b67072851 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -27,6 +27,7 @@ describe('Test users with multiple servers', function () { | |||
27 | let servers: ServerInfo[] = [] | 27 | let servers: ServerInfo[] = [] |
28 | let user: User | 28 | let user: User |
29 | let userAccountName: string | 29 | let userAccountName: string |
30 | let userAccountUUID: string | ||
30 | let userVideoChannelUUID: string | 31 | let userVideoChannelUUID: string |
31 | let userId: number | 32 | let userId: number |
32 | let videoUUID: string | 33 | let videoUUID: string |
@@ -62,7 +63,9 @@ describe('Test users with multiple servers', function () { | |||
62 | 63 | ||
63 | { | 64 | { |
64 | const res = await getMyUserInformation(servers[0].url, userAccessToken) | 65 | const res = await getMyUserInformation(servers[0].url, userAccessToken) |
65 | userAccountName = res.body.account.name + '@' + res.body.account.host | 66 | const account: Account = res.body.account |
67 | userAccountName = account.name + '@' + account.host | ||
68 | userAccountUUID = account.uuid | ||
66 | } | 69 | } |
67 | 70 | ||
68 | { | 71 | { |
@@ -196,7 +199,7 @@ describe('Test users with multiple servers', function () { | |||
196 | 199 | ||
197 | it('Should not have actor files', async () => { | 200 | it('Should not have actor files', async () => { |
198 | for (const server of servers) { | 201 | for (const server of servers) { |
199 | await checkActorFilesWereRemoved(userAccountName, server.serverNumber) | 202 | await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber) |
200 | await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber) | 203 | await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber) |
201 | } | 204 | } |
202 | }) | 205 | }) |
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index 370e69d2a..891148b07 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts | |||
@@ -34,7 +34,7 @@ describe('Test video NSFW policy', function () { | |||
34 | return getMyUserInformation(server.url, server.accessToken) | 34 | return getMyUserInformation(server.url, server.accessToken) |
35 | .then(res => { | 35 | .then(res => { |
36 | const user: User = res.body | 36 | const user: User = res.body |
37 | const videoChannelUUID = user.videoChannels[0].uuid | 37 | const videoChannelName = user.videoChannels[0].name |
38 | const accountName = user.account.name + '@' + user.account.host | 38 | const accountName = user.account.name + '@' + user.account.host |
39 | 39 | ||
40 | if (token) { | 40 | if (token) { |
@@ -42,7 +42,7 @@ describe('Test video NSFW policy', function () { | |||
42 | getVideosListWithToken(server.url, token, query), | 42 | getVideosListWithToken(server.url, token, query), |
43 | searchVideoWithToken(server.url, 'n', token, query), | 43 | searchVideoWithToken(server.url, 'n', token, query), |
44 | getAccountVideos(server.url, token, accountName, 0, 5, undefined, query), | 44 | getAccountVideos(server.url, token, accountName, 0, 5, undefined, query), |
45 | getVideoChannelVideos(server.url, token, videoChannelUUID, 0, 5, undefined, query) | 45 | getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query) |
46 | ]) | 46 | ]) |
47 | } | 47 | } |
48 | 48 | ||
@@ -50,7 +50,7 @@ describe('Test video NSFW policy', function () { | |||
50 | getVideosList(server.url), | 50 | getVideosList(server.url), |
51 | searchVideo(server.url, 'n'), | 51 | searchVideo(server.url, 'n'), |
52 | getAccountVideos(server.url, undefined, accountName, 0, 5), | 52 | getAccountVideos(server.url, undefined, accountName, 0, 5), |
53 | getVideoChannelVideos(server.url, undefined, videoChannelUUID, 0, 5) | 53 | getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5) |
54 | ]) | 54 | ]) |
55 | }) | 55 | }) |
56 | } | 56 | } |
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index 7f54c0e70..b89e72ab7 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts | |||
@@ -94,9 +94,9 @@ describe('Test update host scripts', function () { | |||
94 | expect(res.body.total).to.equal(3) | 94 | expect(res.body.total).to.equal(3) |
95 | 95 | ||
96 | for (const channel of res.body.data) { | 96 | for (const channel of res.body.data) { |
97 | const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.uuid) | 97 | const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.name) |
98 | 98 | ||
99 | expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.uuid) | 99 | expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.name) |
100 | } | 100 | } |
101 | }) | 101 | }) |
102 | 102 | ||