Fix tests

pull/974/head
Chocobozzz 2018-08-23 10:30:53 +02:00
parent 83e6519ba4
commit 240085d005
7 changed files with 15 additions and 14 deletions

View File

@ -39,8 +39,9 @@ export { searchRouter }
function searchVideos (req: express.Request, res: express.Response) {
const query: VideosSearchQuery = req.query
if (query.search.startsWith('http://') || query.search.startsWith('https://')) {
return searchVideoUrl(query.search, res)
const search = query.search
if (search && (search.startsWith('http://') || search.startsWith('https://'))) {
return searchVideoUrl(search, res)
}
return searchVideosDB(query, res)

View File

@ -112,7 +112,7 @@ const JOB_TTL: { [ id in JobType ]: number } = {
'email': 60000 * 10 // 10 minutes
}
const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job
const CRAWL_REQUEST_CONCURRENCY = 5 // How many requests in parallel to fetch remote data (likes, shares...)
const CRAWL_REQUEST_CONCURRENCY = 1 // How many requests in parallel to fetch remote data (likes, shares...)
const JOB_REQUEST_TIMEOUT = 3000 // 3 seconds
const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days

View File

@ -1,5 +1,4 @@
import 'multer'
import * as uuidv4 from 'uuid'
import { sendUpdateActor } from './activitypub/send'
import { AVATARS_SIZE, CONFIG, sequelizeTypescript } from '../initializers'
import { updateActorAvatarInstance } from './activitypub'
@ -15,7 +14,7 @@ async function updateActorAvatarFile (
accountOrChannel: AccountModel | VideoChannelModel
) {
const extension = extname(avatarPhysicalFile.filename)
const avatarName = uuidv4() + extension
const avatarName = actor.uuid + extension
const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName)
await processImage(avatarPhysicalFile, destination, AVATARS_SIZE)

View File

@ -28,7 +28,6 @@ describe('Test video imports API validator', function () {
let userAccessToken = ''
let accountName: string
let channelId: number
let channelUUID: string
// ---------------------------------------------------------------
@ -49,7 +48,6 @@ describe('Test video imports API validator', function () {
{
const res = await getMyUserInformation(server.url, server.accessToken)
channelId = res.body.videoChannels[ 0 ].id
channelUUID = res.body.videoChannels[ 0 ].uuid
accountName = res.body.account.name + '@' + res.body.account.host
}
})

View File

@ -27,6 +27,7 @@ describe('Test users with multiple servers', function () {
let servers: ServerInfo[] = []
let user: User
let userAccountName: string
let userAccountUUID: string
let userVideoChannelUUID: string
let userId: number
let videoUUID: string
@ -62,7 +63,9 @@ describe('Test users with multiple servers', function () {
{
const res = await getMyUserInformation(servers[0].url, userAccessToken)
userAccountName = res.body.account.name + '@' + res.body.account.host
const account: Account = res.body.account
userAccountName = account.name + '@' + account.host
userAccountUUID = account.uuid
}
{
@ -196,7 +199,7 @@ describe('Test users with multiple servers', function () {
it('Should not have actor files', async () => {
for (const server of servers) {
await checkActorFilesWereRemoved(userAccountName, server.serverNumber)
await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber)
await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber)
}
})

View File

@ -34,7 +34,7 @@ describe('Test video NSFW policy', function () {
return getMyUserInformation(server.url, server.accessToken)
.then(res => {
const user: User = res.body
const videoChannelUUID = user.videoChannels[0].uuid
const videoChannelName = user.videoChannels[0].name
const accountName = user.account.name + '@' + user.account.host
if (token) {
@ -42,7 +42,7 @@ describe('Test video NSFW policy', function () {
getVideosListWithToken(server.url, token, query),
searchVideoWithToken(server.url, 'n', token, query),
getAccountVideos(server.url, token, accountName, 0, 5, undefined, query),
getVideoChannelVideos(server.url, token, videoChannelUUID, 0, 5, undefined, query)
getVideoChannelVideos(server.url, token, videoChannelName, 0, 5, undefined, query)
])
}
@ -50,7 +50,7 @@ describe('Test video NSFW policy', function () {
getVideosList(server.url),
searchVideo(server.url, 'n'),
getAccountVideos(server.url, undefined, accountName, 0, 5),
getVideoChannelVideos(server.url, undefined, videoChannelUUID, 0, 5)
getVideoChannelVideos(server.url, undefined, videoChannelName, 0, 5)
])
})
}

View File

@ -94,9 +94,9 @@ describe('Test update host scripts', function () {
expect(res.body.total).to.equal(3)
for (const channel of res.body.data) {
const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.uuid)
const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.name)
expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.uuid)
expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.name)
}
})