aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/cli/update-host.ts65
1 files changed, 62 insertions, 3 deletions
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index d0c6d2042..968b7bd7f 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -3,20 +3,26 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoDetails } from '../../../shared/models/videos' 5import { VideoDetails } from '../../../shared/models/videos'
6import { waitJobs } from '../utils/server/jobs'
7import { addVideoCommentThread } from '../utils/videos/video-comments'
6import { 8import {
9 addVideoChannel,
10 createUser,
7 execCLI, 11 execCLI,
8 flushTests, 12 flushTests,
9 getEnvCli, 13 getEnvCli,
10 getVideo, 14 getVideo,
15 getVideoChannelsList,
11 getVideosList, 16 getVideosList,
12 killallServers, 17 killallServers,
18 makeActivityPubGetRequest,
13 parseTorrentVideo, 19 parseTorrentVideo,
14 runServer, 20 runServer,
15 ServerInfo, 21 ServerInfo,
16 setAccessTokensToServers, 22 setAccessTokensToServers,
17 uploadVideo 23 uploadVideo
18} from '../utils' 24} from '../utils'
19import { waitJobs } from '../utils/server/jobs' 25import { getAccountsList } from '../utils/users/accounts'
20 26
21const expect = chai.expect 27const expect = chai.expect
22 28
@@ -39,13 +45,28 @@ describe('Test update host scripts', function () {
39 45
40 // Upload two videos for our needs 46 // Upload two videos for our needs
41 const videoAttributes = {} 47 const videoAttributes = {}
48 const resVideo1 = await uploadVideo(server.url, server.accessToken, videoAttributes)
49 const video1UUID = resVideo1.body.video.uuid
42 await uploadVideo(server.url, server.accessToken, videoAttributes) 50 await uploadVideo(server.url, server.accessToken, videoAttributes)
43 await uploadVideo(server.url, server.accessToken, videoAttributes) 51
52 // Create a user
53 await createUser(server.url, server.accessToken, 'toto', 'coucou')
54
55 // Create channel
56 const videoChannel = {
57 displayName: 'second video channel',
58 description: 'super video channel description'
59 }
60 await addVideoChannel(server.url, server.accessToken, videoChannel)
61
62 // Create comments
63 const text = 'my super first comment'
64 await addVideoCommentThread(server.url, server.accessToken, video1UUID, text)
44 65
45 await waitJobs(server) 66 await waitJobs(server)
46 }) 67 })
47 68
48 it('Should update torrent hosts', async function () { 69 it('Should run update host', async function () {
49 this.timeout(30000) 70 this.timeout(30000)
50 71
51 killallServers([ server ]) 72 killallServers([ server ])
@@ -54,6 +75,44 @@ describe('Test update host scripts', function () {
54 75
55 const env = getEnvCli(server) 76 const env = getEnvCli(server)
56 await execCLI(`${env} npm run update-host`) 77 await execCLI(`${env} npm run update-host`)
78 })
79
80 it('Should have updated videos url', async function () {
81 const res = await getVideosList(server.url)
82 expect(res.body.total).to.equal(2)
83
84 for (const video of res.body.data) {
85 const { body } = await makeActivityPubGetRequest(server.url, '/videos/watch/' + video.uuid)
86
87 expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid)
88 }
89 })
90
91 it('Should have updated video channels url', async function () {
92 const res = await getVideoChannelsList(server.url, 0, 5, '-name')
93 expect(res.body.total).to.equal(3)
94
95 for (const channel of res.body.data) {
96 const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.uuid)
97
98 expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.uuid)
99 }
100 })
101
102 it('Should have update accounts url', async function () {
103 const res = await getAccountsList(server.url)
104 expect(res.body.total).to.equal(3)
105
106 for (const account of res.body.data) {
107 const usernameWithDomain = account.name
108 const { body } = await makeActivityPubGetRequest(server.url, '/accounts/' + usernameWithDomain)
109
110 expect(body.id).to.equal('http://localhost:9002/accounts/' + usernameWithDomain)
111 }
112 })
113
114 it('Should update torrent hosts', async function () {
115 this.timeout(30000)
57 116
58 const res = await getVideosList(server.url) 117 const res = await getVideosList(server.url)
59 const videos = res.body.data 118 const videos = res.body.data