]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/activitypub/fetch.ts
Introduce server commands
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / fetch.ts
index 5c617de1008ccade89bdb0c22b65797057813fdb..d5e21404c39eeed956022697f6f17142ef8a33a5 100644 (file)
@@ -1,24 +1,19 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
-
+import * as chai from 'chai'
 import {
-  closeAllSequelize,
+  cleanupTests,
   createUser,
   doubleFollow,
   flushAndRunMultipleServers,
-  flushTests,
   getVideosListSort,
-  killallServers,
   ServerInfo,
   setAccessTokensToServers,
-  setActorField,
-  setVideoField,
   uploadVideo,
   userLogin,
   waitJobs
-} from '../../../../shared/utils'
-import * as chai from 'chai'
+} from '../../../../shared/extra-utils'
 import { Video } from '../../../../shared/models/videos'
 
 const expect = chai.expect
@@ -38,7 +33,7 @@ describe('Test ActivityPub fetcher', function () {
 
     const user = { username: 'user1', password: 'password' }
     for (const server of servers) {
-      await createUser(server.url, server.accessToken, user.username, user.password)
+      await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
     }
 
     const userAccessToken = await userLogin(servers[0], user)
@@ -48,8 +43,16 @@ describe('Test ActivityPub fetcher', function () {
     const badVideoUUID = res.body.video.uuid
     await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })
 
-    await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1')
-    await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID)
+    {
+      const to = 'http://localhost:' + servers[0].port + '/accounts/user1'
+      const value = 'http://localhost:' + servers[1].port + '/accounts/user1'
+      await servers[0].sqlCommand.setActorField(to, 'url', value)
+    }
+
+    {
+      const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + badVideoUUID
+      await servers[0].sqlCommand.setVideoField(badVideoUUID, 'url', value)
+    }
   })
 
   it('Should add only the video with a valid actor URL', async function () {
@@ -78,13 +81,8 @@ describe('Test ActivityPub fetcher', function () {
   })
 
   after(async function () {
-    killallServers(servers)
+    this.timeout(20000)
 
-    await closeAllSequelize(servers)
-
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
+    await cleanupTests(servers)
   })
 })