aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/views
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-04-21 15:00:01 +0200
committerChocobozzz <chocobozzz@cpy.re>2023-05-09 08:57:34 +0200
commitd102de1b38f2877463529c3b27bd35ffef4fd8bf (patch)
tree31fa0bdf26ad7a2ee46d600d804a6f03260266c8 /server/tests/api/views
parent2fe978744e5b74eb824e4d79c1bb9b840169f125 (diff)
downloadPeerTube-d102de1b38f2877463529c3b27bd35ffef4fd8bf.tar.gz
PeerTube-d102de1b38f2877463529c3b27bd35ffef4fd8bf.tar.zst
PeerTube-d102de1b38f2877463529c3b27bd35ffef4fd8bf.zip
Add runner server tests
Diffstat (limited to 'server/tests/api/views')
-rw-r--r--server/tests/api/views/videos-views-cleaner.ts42
1 files changed, 21 insertions, 21 deletions
diff --git a/server/tests/api/views/videos-views-cleaner.ts b/server/tests/api/views/videos-views-cleaner.ts
index 7c543a74a..fce2d538c 100644
--- a/server/tests/api/views/videos-views-cleaner.ts
+++ b/server/tests/api/views/videos-views-cleaner.ts
@@ -1,6 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { SQLCommand } from '@server/tests/shared'
4import { wait } from '@shared/core-utils' 5import { wait } from '@shared/core-utils'
5import { 6import {
6 cleanupTests, 7 cleanupTests,
@@ -14,6 +15,7 @@ import {
14 15
15describe('Test video views cleaner', function () { 16describe('Test video views cleaner', function () {
16 let servers: PeerTubeServer[] 17 let servers: PeerTubeServer[]
18 let sqlCommands: SQLCommand[]
17 19
18 let videoIdServer1: string 20 let videoIdServer1: string
19 let videoIdServer2: string 21 let videoIdServer2: string
@@ -37,6 +39,8 @@ describe('Test video views cleaner', function () {
37 await servers[1].views.simulateView({ id: videoIdServer2 }) 39 await servers[1].views.simulateView({ id: videoIdServer2 })
38 40
39 await waitJobs(servers) 41 await waitJobs(servers)
42
43 sqlCommands = servers.map(s => new SQLCommand(s))
40 }) 44 })
41 45
42 it('Should not clean old video views', async function () { 46 it('Should not clean old video views', async function () {
@@ -50,18 +54,14 @@ describe('Test video views cleaner', function () {
50 54
51 // Should still have views 55 // Should still have views
52 56
53 { 57 for (let i = 0; i < servers.length; i++) {
54 for (const server of servers) { 58 const total = await sqlCommands[i].countVideoViewsOf(videoIdServer1)
55 const total = await server.sql.countVideoViewsOf(videoIdServer1) 59 expect(total).to.equal(2, 'Server ' + servers[i].serverNumber + ' does not have the correct amount of views')
56 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
57 }
58 } 60 }
59 61
60 { 62 for (let i = 0; i < servers.length; i++) {
61 for (const server of servers) { 63 const total = await sqlCommands[i].countVideoViewsOf(videoIdServer2)
62 const total = await server.sql.countVideoViewsOf(videoIdServer2) 64 expect(total).to.equal(2, 'Server ' + servers[i].serverNumber + ' does not have the correct amount of views')
63 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
64 }
65 } 65 }
66 }) 66 })
67 67
@@ -76,23 +76,23 @@ describe('Test video views cleaner', function () {
76 76
77 // Should still have views 77 // Should still have views
78 78
79 { 79 for (let i = 0; i < servers.length; i++) {
80 for (const server of servers) { 80 const total = await sqlCommands[i].countVideoViewsOf(videoIdServer1)
81 const total = await server.sql.countVideoViewsOf(videoIdServer1) 81 expect(total).to.equal(2)
82 expect(total).to.equal(2)
83 }
84 } 82 }
85 83
86 { 84 const totalServer1 = await sqlCommands[0].countVideoViewsOf(videoIdServer2)
87 const totalServer1 = await servers[0].sql.countVideoViewsOf(videoIdServer2) 85 expect(totalServer1).to.equal(0)
88 expect(totalServer1).to.equal(0)
89 86
90 const totalServer2 = await servers[1].sql.countVideoViewsOf(videoIdServer2) 87 const totalServer2 = await sqlCommands[1].countVideoViewsOf(videoIdServer2)
91 expect(totalServer2).to.equal(2) 88 expect(totalServer2).to.equal(2)
92 }
93 }) 89 })
94 90
95 after(async function () { 91 after(async function () {
92 for (const sqlCommand of sqlCommands) {
93 await sqlCommand.cleanup()
94 }
95
96 await cleanupTests(servers) 96 await cleanupTests(servers)
97 }) 97 })
98}) 98})