diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-09 15:37:43 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 9293139fde7091e9badcafa9b570b83cea9a10ad (patch) | |
tree | 9728412f02af4aa59d2c016db47624251e8f6be6 /server/tests/api/activitypub/cleaner.ts | |
parent | 078f17e6d90376050f43ce639e88e11869b49ee7 (diff) | |
download | PeerTube-9293139fde7091e9badcafa9b570b83cea9a10ad.tar.gz PeerTube-9293139fde7091e9badcafa9b570b83cea9a10ad.tar.zst PeerTube-9293139fde7091e9badcafa9b570b83cea9a10ad.zip |
Introduce sql command
Diffstat (limited to 'server/tests/api/activitypub/cleaner.ts')
-rw-r--r-- | server/tests/api/activitypub/cleaner.ts | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/server/tests/api/activitypub/cleaner.ts b/server/tests/api/activitypub/cleaner.ts index 27f17b4d6..5b08880bf 100644 --- a/server/tests/api/activitypub/cleaner.ts +++ b/server/tests/api/activitypub/cleaner.ts | |||
@@ -4,18 +4,12 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
7 | closeAllSequelize, | ||
8 | deleteAll, | ||
9 | doubleFollow, | 7 | doubleFollow, |
10 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
11 | getCount, | ||
12 | getVideo, | 9 | getVideo, |
13 | rateVideo, | 10 | rateVideo, |
14 | selectQuery, | ||
15 | ServerInfo, | 11 | ServerInfo, |
16 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
17 | setVideoField, | ||
18 | updateQuery, | ||
19 | uploadVideoAndGetId, | 13 | uploadVideoAndGetId, |
20 | wait, | 14 | wait, |
21 | waitJobs | 15 | waitJobs |
@@ -86,9 +80,9 @@ describe('Test AP cleaner', function () { | |||
86 | it('Should destroy server 3 internal likes and correctly clean them', async function () { | 80 | it('Should destroy server 3 internal likes and correctly clean them', async function () { |
87 | this.timeout(20000) | 81 | this.timeout(20000) |
88 | 82 | ||
89 | await deleteAll(servers[2].internalServerNumber, 'accountVideoRate') | 83 | await servers[2].sqlCommand.deleteAll('accountVideoRate') |
90 | for (const uuid of videoUUIDs) { | 84 | for (const uuid of videoUUIDs) { |
91 | await setVideoField(servers[2].internalServerNumber, uuid, 'likes', '0') | 85 | await servers[2].sqlCommand.setVideoField(uuid, 'likes', '0') |
92 | } | 86 | } |
93 | 87 | ||
94 | await wait(5000) | 88 | await wait(5000) |
@@ -132,10 +126,10 @@ describe('Test AP cleaner', function () { | |||
132 | it('Should destroy server 3 internal dislikes and correctly clean them', async function () { | 126 | it('Should destroy server 3 internal dislikes and correctly clean them', async function () { |
133 | this.timeout(20000) | 127 | this.timeout(20000) |
134 | 128 | ||
135 | await deleteAll(servers[2].internalServerNumber, 'accountVideoRate') | 129 | await servers[2].sqlCommand.deleteAll('accountVideoRate') |
136 | 130 | ||
137 | for (const uuid of videoUUIDs) { | 131 | for (const uuid of videoUUIDs) { |
138 | await setVideoField(servers[2].internalServerNumber, uuid, 'dislikes', '0') | 132 | await servers[2].sqlCommand.setVideoField(uuid, 'dislikes', '0') |
139 | } | 133 | } |
140 | 134 | ||
141 | await wait(5000) | 135 | await wait(5000) |
@@ -159,15 +153,15 @@ describe('Test AP cleaner', function () { | |||
159 | it('Should destroy server 3 internal shares and correctly clean them', async function () { | 153 | it('Should destroy server 3 internal shares and correctly clean them', async function () { |
160 | this.timeout(20000) | 154 | this.timeout(20000) |
161 | 155 | ||
162 | const preCount = await getCount(servers[0].internalServerNumber, 'videoShare') | 156 | const preCount = await servers[0].sqlCommand.getCount('videoShare') |
163 | expect(preCount).to.equal(6) | 157 | expect(preCount).to.equal(6) |
164 | 158 | ||
165 | await deleteAll(servers[2].internalServerNumber, 'videoShare') | 159 | await servers[2].sqlCommand.deleteAll('videoShare') |
166 | await wait(5000) | 160 | await wait(5000) |
167 | await waitJobs(servers) | 161 | await waitJobs(servers) |
168 | 162 | ||
169 | // Still 6 because we don't have remote shares on local videos | 163 | // Still 6 because we don't have remote shares on local videos |
170 | const postCount = await getCount(servers[0].internalServerNumber, 'videoShare') | 164 | const postCount = await servers[0].sqlCommand.getCount('videoShare') |
171 | expect(postCount).to.equal(6) | 165 | expect(postCount).to.equal(6) |
172 | }) | 166 | }) |
173 | 167 | ||
@@ -179,7 +173,7 @@ describe('Test AP cleaner', function () { | |||
179 | expect(total).to.equal(3) | 173 | expect(total).to.equal(3) |
180 | } | 174 | } |
181 | 175 | ||
182 | await deleteAll(servers[2].internalServerNumber, 'videoComment') | 176 | await servers[2].sqlCommand.deleteAll('videoComment') |
183 | 177 | ||
184 | await wait(5000) | 178 | await wait(5000) |
185 | await waitJobs(servers) | 179 | await waitJobs(servers) |
@@ -196,7 +190,7 @@ describe('Test AP cleaner', function () { | |||
196 | async function check (like: string, ofServerUrl: string, urlSuffix: string, remote: 'true' | 'false') { | 190 | async function check (like: string, ofServerUrl: string, urlSuffix: string, remote: 'true' | 'false') { |
197 | const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` + | 191 | const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` + |
198 | `INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'` | 192 | `INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'` |
199 | const res = await selectQuery(servers[0].internalServerNumber, query) | 193 | const res = await servers[0].sqlCommand.selectQuery(query) |
200 | 194 | ||
201 | for (const rate of res) { | 195 | for (const rate of res) { |
202 | const matcher = new RegExp(`^${ofServerUrl}/accounts/root/dislikes/\\d+${urlSuffix}$`) | 196 | const matcher = new RegExp(`^${ofServerUrl}/accounts/root/dislikes/\\d+${urlSuffix}$`) |
@@ -225,7 +219,7 @@ describe('Test AP cleaner', function () { | |||
225 | 219 | ||
226 | { | 220 | { |
227 | const query = `UPDATE "accountVideoRate" SET url = url || 'stan'` | 221 | const query = `UPDATE "accountVideoRate" SET url = url || 'stan'` |
228 | await updateQuery(servers[1].internalServerNumber, query) | 222 | await servers[1].sqlCommand.updateQuery(query) |
229 | 223 | ||
230 | await wait(5000) | 224 | await wait(5000) |
231 | await waitJobs(servers) | 225 | await waitJobs(servers) |
@@ -242,7 +236,7 @@ describe('Test AP cleaner', function () { | |||
242 | const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` + | 236 | const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` + |
243 | `INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'` | 237 | `INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'` |
244 | 238 | ||
245 | const res = await selectQuery(servers[0].internalServerNumber, query) | 239 | const res = await servers[0].sqlCommand.selectQuery(query) |
246 | 240 | ||
247 | for (const comment of res) { | 241 | for (const comment of res) { |
248 | const matcher = new RegExp(`${ofServerUrl}/videos/watch/${comment.videoUUID}/comments/\\d+${urlSuffix}`) | 242 | const matcher = new RegExp(`${ofServerUrl}/videos/watch/${comment.videoUUID}/comments/\\d+${urlSuffix}`) |
@@ -268,7 +262,7 @@ describe('Test AP cleaner', function () { | |||
268 | 262 | ||
269 | { | 263 | { |
270 | const query = `UPDATE "videoComment" SET url = url || 'kyle'` | 264 | const query = `UPDATE "videoComment" SET url = url || 'kyle'` |
271 | await updateQuery(servers[1].internalServerNumber, query) | 265 | await servers[1].sqlCommand.updateQuery(query) |
272 | 266 | ||
273 | await wait(5000) | 267 | await wait(5000) |
274 | await waitJobs(servers) | 268 | await waitJobs(servers) |
@@ -280,7 +274,5 @@ describe('Test AP cleaner', function () { | |||
280 | 274 | ||
281 | after(async function () { | 275 | after(async function () { |
282 | await cleanupTests(servers) | 276 | await cleanupTests(servers) |
283 | |||
284 | await closeAllSequelize(servers) | ||
285 | }) | 277 | }) |
286 | }) | 278 | }) |