1
0
Fork 0

Fix migrations

This commit is contained in:
Chocobozzz 2021-12-17 14:20:43 +01:00
parent f304a1580b
commit 6def7d34e6
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 47 additions and 13 deletions

View File

@ -65,7 +65,7 @@ async function getMigrationScripts () {
}[] = []
files
.filter(file => file.endsWith('.js.map') === false)
.filter(file => file.endsWith('.js'))
.forEach(file => {
// Filename is something like 'version-blabla.js'
const version = file.split('-')[0]

View File

@ -2,6 +2,7 @@
import 'mocha'
import * as chai from 'chai'
import { VideoPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
@ -32,20 +33,18 @@ describe('Test users subscriptions', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
{
for (const server of servers) {
const user = { username: 'user' + server.serverNumber, password: 'password' }
await server.users.create({ username: user.username, password: user.password })
for (const server of servers) {
const user = { username: 'user' + server.serverNumber, password: 'password' }
await server.users.create({ username: user.username, password: user.password })
const accessToken = await server.login.getAccessToken(user)
users.push({ accessToken })
const accessToken = await server.login.getAccessToken(user)
users.push({ accessToken })
const videoName1 = 'video 1-' + server.serverNumber
await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } })
const videoName1 = 'video 1-' + server.serverNumber
await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } })
const videoName2 = 'video 2-' + server.serverNumber
await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } })
}
const videoName2 = 'video 2-' + server.serverNumber
await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } })
}
await waitJobs(servers)
@ -540,6 +539,40 @@ describe('Test users subscriptions', function () {
}
})
it('Should update video as internal and not see from remote server', async function () {
this.timeout(30000)
await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } })
await waitJobs(servers)
{
const { data } = await command.listVideos({ token: users[0].accessToken })
expect(data.find(v => v.name === 'internal')).to.not.exist
}
})
it('Should see internal from local user', async function () {
const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken })
expect(data.find(v => v.name === 'internal')).to.exist
})
it('Should update video as private and not see from anyone server', async function () {
this.timeout(30000)
await servers[2].videos.update({ id: video3UUID, attributes: { name: 'private', privacy: VideoPrivacy.PRIVATE } })
await waitJobs(servers)
{
const { data } = await command.listVideos({ token: users[0].accessToken })
expect(data.find(v => v.name === 'private')).to.not.exist
}
{
const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken })
expect(data.find(v => v.name === 'private')).to.not.exist
}
})
after(async function () {
await cleanupTests(servers)
})

View File

@ -5,7 +5,8 @@ import { program } from 'commander'
import { accessSync, constants } from 'fs'
import { remove } from 'fs-extra'
import { join } from 'path'
import { sha256, wait } from '@shared/core-utils'
import { sha256 } from '@shared/extra-utils'
import { wait } from '@shared/core-utils'
import { doRequestAndSaveToFile } from '../helpers/requests'
import {
assignToken,