1
0
Fork 0

Fix tests

This commit is contained in:
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) { function searchVideos (req: express.Request, res: express.Response) {
const query: VideosSearchQuery = req.query const query: VideosSearchQuery = req.query
if (query.search.startsWith('http://') || query.search.startsWith('https://')) { const search = query.search
return searchVideoUrl(query.search, res) if (search && (search.startsWith('http://') || search.startsWith('https://'))) {
return searchVideoUrl(search, res)
} }
return searchVideosDB(query, res) return searchVideosDB(query, res)

View file

@ -112,7 +112,7 @@ const JOB_TTL: { [ id in JobType ]: number } = {
'email': 60000 * 10 // 10 minutes 'email': 60000 * 10 // 10 minutes
} }
const BROADCAST_CONCURRENCY = 10 // How many requests in parallel we do in activitypub-http-broadcast job 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_REQUEST_TIMEOUT = 3000 // 3 seconds
const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2 // 2 days

View file

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

View file

@ -28,7 +28,6 @@ describe('Test video imports API validator', function () {
let userAccessToken = '' let userAccessToken = ''
let accountName: string let accountName: string
let channelId: number 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) const res = await getMyUserInformation(server.url, server.accessToken)
channelId = res.body.videoChannels[ 0 ].id channelId = res.body.videoChannels[ 0 ].id
channelUUID = res.body.videoChannels[ 0 ].uuid
accountName = res.body.account.name + '@' + res.body.account.host 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 servers: ServerInfo[] = []
let user: User let user: User
let userAccountName: string let userAccountName: string
let userAccountUUID: string
let userVideoChannelUUID: string let userVideoChannelUUID: string
let userId: number let userId: number
let videoUUID: string let videoUUID: string
@ -62,7 +63,9 @@ describe('Test users with multiple servers', function () {
{ {
const res = await getMyUserInformation(servers[0].url, userAccessToken) 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 () => { it('Should not have actor files', async () => {
for (const server of servers) { for (const server of servers) {
await checkActorFilesWereRemoved(userAccountName, server.serverNumber) await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber)
await checkActorFilesWereRemoved(userVideoChannelUUID, 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) return getMyUserInformation(server.url, server.accessToken)
.then(res => { .then(res => {
const user: User = res.body 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 const accountName = user.account.name + '@' + user.account.host
if (token) { if (token) {
@ -42,7 +42,7 @@ describe('Test video NSFW policy', function () {
getVideosListWithToken(server.url, token, query), getVideosListWithToken(server.url, token, query),
searchVideoWithToken(server.url, 'n', token, query), searchVideoWithToken(server.url, 'n', token, query),
getAccountVideos(server.url, token, accountName, 0, 5, undefined, 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), getVideosList(server.url),
searchVideo(server.url, 'n'), searchVideo(server.url, 'n'),
getAccountVideos(server.url, undefined, accountName, 0, 5), 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) expect(res.body.total).to.equal(3)
for (const channel of res.body.data) { 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)
} }
}) })