]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/live/live-save-replay.ts
emit more specific status codes on video upload (#3423)
[github/Chocobozzz/PeerTube.git] / server / tests / api / live / live-save-replay.ts
index 3ffa0c093ccb721cab69aa589c380d505acc8129..e300ec34567ec7981dd1aba8c05e0abad4b99b0f 100644 (file)
@@ -25,6 +25,7 @@ import {
   waitJobs,
   waitUntilLiveStarts
 } from '../../../../shared/extra-utils'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
 
 const expect = chai.expect
 
@@ -118,7 +119,7 @@ describe('Save replay setting', function () {
 
       await waitJobs(servers)
 
-      await checkVideosExist(liveVideoUUID, false, 200)
+      await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
       await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE)
     })
 
@@ -130,7 +131,7 @@ describe('Save replay setting', function () {
 
       await waitJobs(servers)
 
-      await checkVideosExist(liveVideoUUID, true, 200)
+      await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
       await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
     })
 
@@ -142,7 +143,7 @@ describe('Save replay setting', function () {
       await waitJobs(servers)
 
       // Live still exist, but cannot be played anymore
-      await checkVideosExist(liveVideoUUID, false, 200)
+      await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
       await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED)
 
       // No resolutions saved since we did not save replay
@@ -158,7 +159,7 @@ describe('Save replay setting', function () {
       await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
 
       await waitJobs(servers)
-      await checkVideosExist(liveVideoUUID, true, 200)
+      await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
 
       await Promise.all([
         addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true),
@@ -169,8 +170,8 @@ describe('Save replay setting', function () {
 
       await checkVideosExist(liveVideoUUID, false)
 
-      await getVideo(servers[0].url, liveVideoUUID, 401)
-      await getVideo(servers[1].url, liveVideoUUID, 404)
+      await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
+      await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
 
       await checkLiveCleanup(servers[0], liveVideoUUID, [])
     })
@@ -184,7 +185,7 @@ describe('Save replay setting', function () {
       await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
 
       await waitJobs(servers)
-      await checkVideosExist(liveVideoUUID, true, 200)
+      await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
 
       await Promise.all([
         testFfmpegStreamError(ffmpegCommand, true),
@@ -193,7 +194,7 @@ describe('Save replay setting', function () {
 
       await waitJobs(servers)
 
-      await checkVideosExist(liveVideoUUID, false, 404)
+      await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
       await checkLiveCleanup(servers[0], liveVideoUUID, [])
     })
   })
@@ -207,7 +208,7 @@ describe('Save replay setting', function () {
 
       await waitJobs(servers)
 
-      await checkVideosExist(liveVideoUUID, false, 200)
+      await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
       await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE)
     })
 
@@ -219,7 +220,7 @@ describe('Save replay setting', function () {
 
       await waitJobs(servers)
 
-      await checkVideosExist(liveVideoUUID, true, 200)
+      await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
       await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
     })
 
@@ -231,7 +232,7 @@ describe('Save replay setting', function () {
       await waitJobs(servers)
 
       // Live has been transcoded
-      await checkVideosExist(liveVideoUUID, true, 200)
+      await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
       await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
     })
 
@@ -261,7 +262,7 @@ describe('Save replay setting', function () {
       await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
 
       await waitJobs(servers)
-      await checkVideosExist(liveVideoUUID, true, 200)
+      await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
 
       await Promise.all([
         addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true),
@@ -272,8 +273,8 @@ describe('Save replay setting', function () {
 
       await checkVideosExist(liveVideoUUID, false)
 
-      await getVideo(servers[0].url, liveVideoUUID, 401)
-      await getVideo(servers[1].url, liveVideoUUID, 404)
+      await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
+      await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
 
       await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ])
     })
@@ -287,7 +288,7 @@ describe('Save replay setting', function () {
       await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
 
       await waitJobs(servers)
-      await checkVideosExist(liveVideoUUID, true, 200)
+      await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
 
       await Promise.all([
         removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID),
@@ -296,7 +297,7 @@ describe('Save replay setting', function () {
 
       await waitJobs(servers)
 
-      await checkVideosExist(liveVideoUUID, false, 404)
+      await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
       await checkLiveCleanup(servers[0], liveVideoUUID, [])
     })
   })