aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-04 13:57:56 +0200
committerChocobozzz <me@florianbigard.com>2022-10-04 13:57:56 +0200
commit7dd7ff4cebc290b09fe00d82046bb58e4e8a800d (patch)
tree50769811d4332f107b0db7908e1a9cbe317c19bf
parente37ca6cbc7d20ad773389efa289f8552fa28fc75 (diff)
downloadPeerTube-7dd7ff4cebc290b09fe00d82046bb58e4e8a800d.tar.gz
PeerTube-7dd7ff4cebc290b09fe00d82046bb58e4e8a800d.tar.zst
PeerTube-7dd7ff4cebc290b09fe00d82046bb58e4e8a800d.zip
Fix tests
-rw-r--r--server/tests/api/redundancy/redundancy.ts6
-rw-r--r--shared/server-commands/requests/requests.ts7
2 files changed, 9 insertions, 4 deletions
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 0f4973184..f349a7a76 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -5,7 +5,7 @@ import { readdir } from 'fs-extra'
5import magnetUtil from 'magnet-uri' 5import magnetUtil from 'magnet-uri'
6import { basename, join } from 'path' 6import { basename, join } from 'path'
7import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared' 7import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared'
8import { root, wait } from '@shared/core-utils' 8import { wait } from '@shared/core-utils'
9import { 9import {
10 HttpStatusCode, 10 HttpStatusCode,
11 VideoDetails, 11 VideoDetails,
@@ -164,7 +164,7 @@ async function check2Webseeds (videoUUID?: string) {
164 ] 164 ]
165 165
166 for (const directory of directories) { 166 for (const directory of directories) {
167 const files = await readdir(join(root(), directory)) 167 const files = await readdir(directory)
168 expect(files).to.have.length.at.least(4) 168 expect(files).to.have.length.at.least(4)
169 169
170 // Ensure we files exist on disk 170 // Ensure we files exist on disk
@@ -219,7 +219,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
219 ] 219 ]
220 220
221 for (const directory of directories) { 221 for (const directory of directories) {
222 const files = await readdir(join(root(), directory, videoUUID)) 222 const files = await readdir(join(directory, videoUUID))
223 expect(files).to.have.length.at.least(4) 223 expect(files).to.have.length.at.least(4)
224 224
225 // Ensure we files exist on disk 225 // Ensure we files exist on disk
diff --git a/shared/server-commands/requests/requests.ts b/shared/server-commands/requests/requests.ts
index 85cbc9be9..8cc1245e0 100644
--- a/shared/server-commands/requests/requests.ts
+++ b/shared/server-commands/requests/requests.ts
@@ -134,7 +134,12 @@ function unwrapText (test: request.Test): Promise<string> {
134function unwrapBodyOrDecodeToJSON <T> (test: request.Test): Promise<T> { 134function unwrapBodyOrDecodeToJSON <T> (test: request.Test): Promise<T> {
135 return test.then(res => { 135 return test.then(res => {
136 if (res.body instanceof Buffer) { 136 if (res.body instanceof Buffer) {
137 return JSON.parse(new TextDecoder().decode(res.body)) 137 try {
138 return JSON.parse(new TextDecoder().decode(res.body))
139 } catch (err) {
140 console.error('Cannot decode JSON.', res.body)
141 throw err
142 }
138 } 143 }
139 144
140 return res.body 145 return res.body