]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/logs.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / logs.ts
index 2d141fd8c457dc16643a0efa5f431e83848fd265..697f10337980a27822c0df4eb1fd0b4e841b5e24 100644 (file)
@@ -4,25 +4,24 @@ import 'mocha'
 import * as chai from 'chai'
 import {
   cleanupTests,
-  flushAndRunServer,
+  createSingleServer,
   killallServers,
   LogsCommand,
-  reRunServer,
-  ServerInfo,
+  PeerTubeServer,
   setAccessTokensToServers,
   waitJobs
-} from '@shared/extra-utils'
+} from '@shared/server-commands'
 
 const expect = chai.expect
 
 describe('Test logs', function () {
-  let server: ServerInfo
+  let server: PeerTubeServer
   let logsCommand: LogsCommand
 
   before(async function () {
     this.timeout(30000)
 
-    server = await flushAndRunServer(1)
+    server = await createSingleServer(1)
     await setAccessTokensToServers([ server ])
 
     logsCommand = server.logs
@@ -72,7 +71,7 @@ describe('Test logs', function () {
       expect(logsString.includes('video 5')).to.be.false
     })
 
-    it('Should get filter by level', async function () {
+    it('Should filter by level', async function () {
       this.timeout(20000)
 
       const now = new Date()
@@ -95,6 +94,27 @@ describe('Test logs', function () {
       }
     })
 
+    it('Should filter by tag', async function () {
+      const now = new Date()
+
+      const { uuid } = await server.videos.upload({ attributes: { name: 'video 6' } })
+      await waitJobs([ server ])
+
+      {
+        const body = await logsCommand.getLogs({ startDate: now, level: 'debug', tagsOneOf: [ 'toto' ] })
+        expect(body).to.have.lengthOf(0)
+      }
+
+      {
+        const body = await logsCommand.getLogs({ startDate: now, level: 'debug', tagsOneOf: [ uuid ] })
+        expect(body).to.not.have.lengthOf(0)
+
+        for (const line of body) {
+          expect(line.tags).to.contain(uuid)
+        }
+      }
+    })
+
     it('Should log ping requests', async function () {
       this.timeout(10000)
 
@@ -113,7 +133,7 @@ describe('Test logs', function () {
 
       await killallServers([ server ])
 
-      await reRunServer(server, { log: { log_ping_requests: false } })
+      await server.run({ log: { log_ping_requests: false } })
 
       const now = new Date()