diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-07 14:32:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 14:32:36 +0100 |
commit | 2d53be0267acc49cda46707b885096193a1f4e9c (patch) | |
tree | 887061a34bc67f40acbb96a6278f9544bf83caeb /server/tests/api/check-params/video-imports.ts | |
parent | adc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff) | |
download | PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip |
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/tests/api/check-params/video-imports.ts')
-rw-r--r-- | server/tests/api/check-params/video-imports.ts | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index f954ba089..49ff96117 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -24,6 +24,7 @@ import { | |||
24 | } from '../../../../shared/extra-utils/requests/check-api-params' | 24 | } from '../../../../shared/extra-utils/requests/check-api-params' |
25 | import { getMagnetURI, getGoodVideoUrl } from '../../../../shared/extra-utils/videos/video-imports' | 25 | import { getMagnetURI, getGoodVideoUrl } from '../../../../shared/extra-utils/videos/video-imports' |
26 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | 26 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' |
27 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
27 | 28 | ||
28 | describe('Test video imports API validator', function () { | 29 | describe('Test video imports API validator', function () { |
29 | const path = '/api/v1/videos/imports' | 30 | const path = '/api/v1/videos/imports' |
@@ -67,7 +68,7 @@ describe('Test video imports API validator', function () { | |||
67 | }) | 68 | }) |
68 | 69 | ||
69 | it('Should success with the correct parameters', async function () { | 70 | it('Should success with the correct parameters', async function () { |
70 | await makeGetRequest({ url: server.url, path: myPath, statusCodeExpected: 200, token: server.accessToken }) | 71 | await makeGetRequest({ url: server.url, path: myPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) |
71 | }) | 72 | }) |
72 | }) | 73 | }) |
73 | 74 | ||
@@ -100,7 +101,13 @@ describe('Test video imports API validator', function () { | |||
100 | 101 | ||
101 | it('Should fail without a target url', async function () { | 102 | it('Should fail without a target url', async function () { |
102 | const fields = omit(baseCorrectParams, 'targetUrl') | 103 | const fields = omit(baseCorrectParams, 'targetUrl') |
103 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 400 }) | 104 | await makePostBodyRequest({ |
105 | url: server.url, | ||
106 | path, | ||
107 | token: server.accessToken, | ||
108 | fields, | ||
109 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | ||
110 | }) | ||
104 | }) | 111 | }) |
105 | 112 | ||
106 | it('Should fail with a bad target url', async function () { | 113 | it('Should fail with a bad target url', async function () { |
@@ -251,7 +258,7 @@ describe('Test video imports API validator', function () { | |||
251 | path, | 258 | path, |
252 | token: server.accessToken, | 259 | token: server.accessToken, |
253 | fields: baseCorrectParams, | 260 | fields: baseCorrectParams, |
254 | statusCodeExpected: 200 | 261 | statusCodeExpected: HttpStatusCode.OK_200 |
255 | }) | 262 | }) |
256 | }) | 263 | }) |
257 | 264 | ||
@@ -274,7 +281,7 @@ describe('Test video imports API validator', function () { | |||
274 | path, | 281 | path, |
275 | token: server.accessToken, | 282 | token: server.accessToken, |
276 | fields: baseCorrectParams, | 283 | fields: baseCorrectParams, |
277 | statusCodeExpected: 409 | 284 | statusCodeExpected: HttpStatusCode.CONFLICT_409 |
278 | }) | 285 | }) |
279 | }) | 286 | }) |
280 | 287 | ||
@@ -295,14 +302,27 @@ describe('Test video imports API validator', function () { | |||
295 | let fields = omit(baseCorrectParams, 'targetUrl') | 302 | let fields = omit(baseCorrectParams, 'targetUrl') |
296 | fields = immutableAssign(fields, { magnetUri: getMagnetURI() }) | 303 | fields = immutableAssign(fields, { magnetUri: getMagnetURI() }) |
297 | 304 | ||
298 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 }) | 305 | await makePostBodyRequest({ |
306 | url: server.url, | ||
307 | path, | ||
308 | token: server.accessToken, | ||
309 | fields, | ||
310 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | ||
311 | }) | ||
299 | 312 | ||
300 | fields = omit(fields, 'magnetUri') | 313 | fields = omit(fields, 'magnetUri') |
301 | const attaches = { | 314 | const attaches = { |
302 | torrentfile: join(__dirname, '..', '..', 'fixtures', 'video-720p.torrent') | 315 | torrentfile: join(__dirname, '..', '..', 'fixtures', 'video-720p.torrent') |
303 | } | 316 | } |
304 | 317 | ||
305 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 409 }) | 318 | await makeUploadRequest({ |
319 | url: server.url, | ||
320 | path, | ||
321 | token: server.accessToken, | ||
322 | fields, | ||
323 | attaches, | ||
324 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | ||
325 | }) | ||
306 | }) | 326 | }) |
307 | }) | 327 | }) |
308 | 328 | ||