1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Use got instead of request

This commit is contained in:
Chocobozzz 2021-03-08 14:24:11 +01:00
parent 71926aae07
commit db4b15f21f
No known key found for this signature in database
GPG key ID: 583A612D890159BE
32 changed files with 346 additions and 328 deletions

View file

@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'
import { get4KFileUrl, root, wait } from '../../../shared/extra-utils'
import { join } from 'path'
import { pathExists, remove } from 'fs-extra'
import { expect } from 'chai'
import { pathExists, remove } from 'fs-extra'
import { join } from 'path'
import { get4KFileUrl, root, wait } from '../../../shared/extra-utils'
import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'
describe('Request helpers', function () {
const destPath1 = join(root(), 'test-output-1.txt')
@ -13,7 +13,7 @@ describe('Request helpers', function () {
it('Should throw an error when the bytes limit is exceeded for request', async function () {
try {
await doRequest({ uri: get4KFileUrl() }, 3)
await doRequest(get4KFileUrl(), { bodyKBLimit: 3 })
} catch {
return
}
@ -23,7 +23,7 @@ describe('Request helpers', function () {
it('Should throw an error when the bytes limit is exceeded for request and save file', async function () {
try {
await doRequestAndSaveToFile({ uri: get4KFileUrl() }, destPath1, 3)
await doRequestAndSaveToFile(get4KFileUrl(), destPath1, { bodyKBLimit: 3 })
} catch {
await wait(500)
@ -35,8 +35,8 @@ describe('Request helpers', function () {
})
it('Should succeed if the file is below the limit', async function () {
await doRequest({ uri: get4KFileUrl() }, 5)
await doRequestAndSaveToFile({ uri: get4KFileUrl() }, destPath2, 5)
await doRequest(get4KFileUrl(), { bodyKBLimit: 5 })
await doRequestAndSaveToFile(get4KFileUrl(), destPath2, { bodyKBLimit: 5 })
expect(await pathExists(destPath2)).to.be.true
})