aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-13 10:22:54 +0200
committerChocobozzz <me@florianbigard.com>2019-08-13 10:22:54 +0200
commit9e3e3617dcea3e31dea60c4d41c9927da98cd560 (patch)
treee4a3234f99383f3198382c58cb595c031f463a04 /server
parentfb1b0ed9f709ef519d0f52bcb2048c10a8c8cfc0 (diff)
downloadPeerTube-9e3e3617dcea3e31dea60c4d41c9927da98cd560.tar.gz
PeerTube-9e3e3617dcea3e31dea60c4d41c9927da98cd560.tar.zst
PeerTube-9e3e3617dcea3e31dea60c4d41c9927da98cd560.zip
Fix redundancy tests
Diffstat (limited to 'server')
-rw-r--r--server/models/redundancy/video-redundancy.ts3
-rw-r--r--server/tests/api/redundancy/redundancy.ts8
2 files changed, 7 insertions, 4 deletions
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts
index 8621a5c6c..3df1c4f9c 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -237,6 +237,8 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
237 237
238 static async getVideoSample (p: Bluebird<VideoModel[]>) { 238 static async getVideoSample (p: Bluebird<VideoModel[]>) {
239 const rows = await p 239 const rows = await p
240 if (rows.length === 0) return undefined
241
240 const ids = rows.map(r => r.id) 242 const ids = rows.map(r => r.id)
241 const id = sample(ids) 243 const id = sample(ids)
242 244
@@ -347,6 +349,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
347 required: true, 349 required: true,
348 include: [ 350 include: [
349 { 351 {
352 required: true,
350 attributes: [], 353 attributes: [],
351 model: VideoStreamingPlaylistModel.unscoped(), 354 model: VideoStreamingPlaylistModel.unscoped(),
352 include: [ 355 include: [
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 6f2c59076..9e8733774 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -66,7 +66,7 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy, additional
66 immutableAssign({ 66 immutableAssign({
67 min_lifetime: '1 hour', 67 min_lifetime: '1 hour',
68 strategy: strategy, 68 strategy: strategy,
69 size: '200KB' 69 size: '400KB'
70 }, additionalParams) 70 }, additionalParams)
71 ] 71 ]
72 } 72 }
@@ -224,8 +224,8 @@ async function checkStatsWith2Webseed (strategy: VideoRedundancyStrategy) {
224 const stat = data.videosRedundancy[0] 224 const stat = data.videosRedundancy[0]
225 225
226 expect(stat.strategy).to.equal(strategy) 226 expect(stat.strategy).to.equal(strategy)
227 expect(stat.totalSize).to.equal(204800) 227 expect(stat.totalSize).to.equal(409600)
228 expect(stat.totalUsed).to.be.at.least(1).and.below(204801) 228 expect(stat.totalUsed).to.be.at.least(1).and.below(409601)
229 expect(stat.totalVideoFiles).to.equal(4) 229 expect(stat.totalVideoFiles).to.equal(4)
230 expect(stat.totalVideos).to.equal(1) 230 expect(stat.totalVideos).to.equal(1)
231} 231}
@@ -238,7 +238,7 @@ async function checkStatsWith1Webseed (strategy: VideoRedundancyStrategy) {
238 238
239 const stat = data.videosRedundancy[0] 239 const stat = data.videosRedundancy[0]
240 expect(stat.strategy).to.equal(strategy) 240 expect(stat.strategy).to.equal(strategy)
241 expect(stat.totalSize).to.equal(204800) 241 expect(stat.totalSize).to.equal(409600)
242 expect(stat.totalUsed).to.equal(0) 242 expect(stat.totalUsed).to.equal(0)
243 expect(stat.totalVideoFiles).to.equal(0) 243 expect(stat.totalVideoFiles).to.equal(0)
244 expect(stat.totalVideos).to.equal(0) 244 expect(stat.totalVideos).to.equal(0)