aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/videos-views-cleaner.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-09 15:37:43 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit9293139fde7091e9badcafa9b570b83cea9a10ad (patch)
tree9728412f02af4aa59d2c016db47624251e8f6be6 /server/tests/api/videos/videos-views-cleaner.ts
parent078f17e6d90376050f43ce639e88e11869b49ee7 (diff)
downloadPeerTube-9293139fde7091e9badcafa9b570b83cea9a10ad.tar.gz
PeerTube-9293139fde7091e9badcafa9b570b83cea9a10ad.tar.zst
PeerTube-9293139fde7091e9badcafa9b570b83cea9a10ad.zip
Introduce sql command
Diffstat (limited to 'server/tests/api/videos/videos-views-cleaner.ts')
-rw-r--r--server/tests/api/videos/videos-views-cleaner.ts20
1 files changed, 8 insertions, 12 deletions
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts
index b89f33217..b6cde6b50 100644
--- a/server/tests/api/videos/videos-views-cleaner.ts
+++ b/server/tests/api/videos/videos-views-cleaner.ts
@@ -1,11 +1,9 @@
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 * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 closeAllSequelize,
8 countVideoViewsOf,
9 doubleFollow, 7 doubleFollow,
10 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
11 killallServers, 9 killallServers,
@@ -50,7 +48,7 @@ describe('Test video views cleaner', function () {
50 it('Should not clean old video views', async function () { 48 it('Should not clean old video views', async function () {
51 this.timeout(50000) 49 this.timeout(50000)
52 50
53 killallServers([ servers[0] ]) 51 await killallServers([ servers[0] ])
54 52
55 await reRunServer(servers[0], { views: { videos: { remote: { max_age: '10 days' } } } }) 53 await reRunServer(servers[0], { views: { videos: { remote: { max_age: '10 days' } } } })
56 54
@@ -60,14 +58,14 @@ describe('Test video views cleaner', function () {
60 58
61 { 59 {
62 for (const server of servers) { 60 for (const server of servers) {
63 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) 61 const total = await server.sqlCommand.countVideoViewsOf(videoIdServer1)
64 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') 62 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
65 } 63 }
66 } 64 }
67 65
68 { 66 {
69 for (const server of servers) { 67 for (const server of servers) {
70 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2) 68 const total = await server.sqlCommand.countVideoViewsOf(videoIdServer2)
71 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') 69 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
72 } 70 }
73 } 71 }
@@ -76,7 +74,7 @@ describe('Test video views cleaner', function () {
76 it('Should clean old video views', async function () { 74 it('Should clean old video views', async function () {
77 this.timeout(50000) 75 this.timeout(50000)
78 76
79 killallServers([ servers[0] ]) 77 await killallServers([ servers[0] ])
80 78
81 await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } }) 79 await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } })
82 80
@@ -86,23 +84,21 @@ describe('Test video views cleaner', function () {
86 84
87 { 85 {
88 for (const server of servers) { 86 for (const server of servers) {
89 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) 87 const total = await server.sqlCommand.countVideoViewsOf(videoIdServer1)
90 expect(total).to.equal(2) 88 expect(total).to.equal(2)
91 } 89 }
92 } 90 }
93 91
94 { 92 {
95 const totalServer1 = await countVideoViewsOf(servers[0].internalServerNumber, videoIdServer2) 93 const totalServer1 = await servers[0].sqlCommand.countVideoViewsOf(videoIdServer2)
96 expect(totalServer1).to.equal(0) 94 expect(totalServer1).to.equal(0)
97 95
98 const totalServer2 = await countVideoViewsOf(servers[1].internalServerNumber, videoIdServer2) 96 const totalServer2 = await servers[1].sqlCommand.countVideoViewsOf(videoIdServer2)
99 expect(totalServer2).to.equal(2) 97 expect(totalServer2).to.equal(2)
100 } 98 }
101 }) 99 })
102 100
103 after(async function () { 101 after(async function () {
104 await closeAllSequelize(servers)
105
106 await cleanupTests(servers) 102 await cleanupTests(servers)
107 }) 103 })
108}) 104})