Reimplement a typed omit function
This commit is contained in:
parent
a85d530384
commit
bbd5aa7ead
|
@ -1,11 +1,11 @@
|
||||||
import { stat } from 'fs-extra'
|
import { stat } from 'fs-extra'
|
||||||
import { omit } from 'lodash'
|
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { format as sqlFormat } from 'sql-formatter'
|
import { format as sqlFormat } from 'sql-formatter'
|
||||||
import { createLogger, format, transports } from 'winston'
|
import { createLogger, format, transports } from 'winston'
|
||||||
import { FileTransportOptions } from 'winston/lib/winston/transports'
|
import { FileTransportOptions } from 'winston/lib/winston/transports'
|
||||||
import { context } from '@opentelemetry/api'
|
import { context } from '@opentelemetry/api'
|
||||||
import { getSpanContext } from '@opentelemetry/api/build/src/trace/context-utils'
|
import { getSpanContext } from '@opentelemetry/api/build/src/trace/context-utils'
|
||||||
|
import { omit } from '@shared/core-utils'
|
||||||
import { CONFIG } from '../initializers/config'
|
import { CONFIG } from '../initializers/config'
|
||||||
import { LOG_FILENAME } from '../initializers/constants'
|
import { LOG_FILENAME } from '../initializers/constants'
|
||||||
|
|
||||||
|
@ -204,5 +204,5 @@ function removeCyclicValues () {
|
||||||
function getAdditionalInfo (info: any) {
|
function getAdditionalInfo (info: any) {
|
||||||
const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql', 'tags' ]
|
const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql', 'tags' ]
|
||||||
|
|
||||||
return omit(info, ...toOmit)
|
return omit(info, toOmit)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
import { merge } from 'lodash'
|
||||||
import 'mocha'
|
import { omit } from '@shared/core-utils'
|
||||||
import { merge, omit } from 'lodash'
|
|
||||||
import { CustomConfig, HttpStatusCode } from '@shared/models'
|
import { CustomConfig, HttpStatusCode } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
@ -277,7 +276,7 @@ describe('Test config API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail if it misses a key', async function () {
|
it('Should fail if it misses a key', async function () {
|
||||||
const newUpdateParams = omit(updateParams, 'admin.email')
|
const newUpdateParams = { ...updateParams, admin: omit(updateParams.admin, [ 'email' ]) }
|
||||||
|
|
||||||
await makePutBodyRequest({
|
await makePutBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { omit } from 'lodash'
|
import { buildAbsoluteFixturePath, omit } from '@shared/core-utils'
|
||||||
import { buildAbsoluteFixturePath } from '@shared/core-utils'
|
|
||||||
import { HttpStatusCode, LiveVideoLatencyMode, VideoCreateResult, VideoPrivacy } from '@shared/models'
|
import { HttpStatusCode, LiveVideoLatencyMode, VideoCreateResult, VideoPrivacy } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
@ -132,7 +130,7 @@ describe('Test video lives API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without a channel', async function () {
|
it('Should fail without a channel', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'channelId')
|
const fields = omit(baseCorrectParams, [ 'channelId' ])
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
import { omit } from '@shared/core-utils'
|
||||||
import { omit } from 'lodash'
|
|
||||||
import { HttpStatusCode, PlaybackMetricCreate, VideoResolution } from '@shared/models'
|
import { HttpStatusCode, PlaybackMetricCreate, VideoResolution } from '@shared/models'
|
||||||
import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
|
import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
|
||||||
|
|
||||||
|
@ -66,7 +65,7 @@ describe('Test metrics API validators', function () {
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
path,
|
path,
|
||||||
fields: omit(baseParams, 'playerMode')
|
fields: omit(baseParams, [ 'playerMode' ])
|
||||||
})
|
})
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
|
@ -80,7 +79,7 @@ describe('Test metrics API validators', function () {
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
path,
|
path,
|
||||||
fields: omit(baseParams, 'resolutionChanges')
|
fields: omit(baseParams, [ 'resolutionChanges' ])
|
||||||
})
|
})
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
|
@ -98,7 +97,7 @@ describe('Test metrics API validators', function () {
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
path,
|
path,
|
||||||
fields: omit(baseParams, 'errors')
|
fields: omit(baseParams, [ 'errors' ])
|
||||||
})
|
})
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
|
@ -112,7 +111,7 @@ describe('Test metrics API validators', function () {
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
path,
|
path,
|
||||||
fields: omit(baseParams, 'downloadedBytesP2P')
|
fields: omit(baseParams, [ 'downloadedBytesP2P' ])
|
||||||
})
|
})
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
|
@ -126,7 +125,7 @@ describe('Test metrics API validators', function () {
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
path,
|
path,
|
||||||
fields: omit(baseParams, 'downloadedBytesHTTP')
|
fields: omit(baseParams, [ 'downloadedBytesHTTP' ])
|
||||||
})
|
})
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
|
@ -140,7 +139,7 @@ describe('Test metrics API validators', function () {
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
path,
|
path,
|
||||||
fields: omit(baseParams, 'uploadedBytesP2P')
|
fields: omit(baseParams, [ 'uploadedBytesP2P' ])
|
||||||
})
|
})
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
|
||||||
import { omit } from 'lodash'
|
|
||||||
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared'
|
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared'
|
||||||
|
import { omit } from '@shared/core-utils'
|
||||||
import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models'
|
import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
@ -123,7 +122,7 @@ describe('Test users admin API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a missing email', async function () {
|
it('Should fail with a missing email', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'email')
|
const fields = omit(baseCorrectParams, [ 'email' ])
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -223,13 +222,13 @@ describe('Test users admin API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without a videoQuota', async function () {
|
it('Should fail without a videoQuota', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'videoQuota')
|
const fields = omit(baseCorrectParams, [ 'videoQuota' ])
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without a videoQuotaDaily', async function () {
|
it('Should fail without a videoQuotaDaily', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'videoQuotaDaily')
|
const fields = omit(baseCorrectParams, [ 'videoQuotaDaily' ])
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -247,7 +246,7 @@ describe('Test users admin API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without a user role', async function () {
|
it('Should fail without a user role', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'role')
|
const fields = omit(baseCorrectParams, [ 'role' ])
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
|
||||||
import { omit } from 'lodash'
|
|
||||||
import { MockSmtpServer } from '@server/tests/shared'
|
import { MockSmtpServer } from '@server/tests/shared'
|
||||||
|
import { omit } from '@shared/core-utils'
|
||||||
import { HttpStatusCode, UserRole } from '@shared/models'
|
import { HttpStatusCode, UserRole } from '@shared/models'
|
||||||
import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
|
import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
|
||||||
|
|
||||||
|
@ -57,7 +55,7 @@ describe('Test users API validators', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with a missing email', async function () {
|
it('Should fail with a missing email', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'email')
|
const fields = omit(baseCorrectParams, [ 'email' ])
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
import { expect } from 'chai'
|
||||||
import * as chai from 'chai'
|
|
||||||
import { omit } from 'lodash'
|
|
||||||
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
|
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
|
||||||
import { buildAbsoluteFixturePath } from '@shared/core-utils'
|
import { buildAbsoluteFixturePath, omit } from '@shared/core-utils'
|
||||||
import { HttpStatusCode, VideoChannelUpdate } from '@shared/models'
|
import { HttpStatusCode, VideoChannelUpdate } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
ChannelsCommand,
|
ChannelsCommand,
|
||||||
|
@ -18,8 +16,6 @@ import {
|
||||||
setAccessTokensToServers
|
setAccessTokensToServers
|
||||||
} from '@shared/server-commands'
|
} from '@shared/server-commands'
|
||||||
|
|
||||||
const expect = chai.expect
|
|
||||||
|
|
||||||
describe('Test video channels API validator', function () {
|
describe('Test video channels API validator', function () {
|
||||||
const videoChannelPath = '/api/v1/video-channels'
|
const videoChannelPath = '/api/v1/video-channels'
|
||||||
let server: PeerTubeServer
|
let server: PeerTubeServer
|
||||||
|
@ -121,7 +117,7 @@ describe('Test video channels API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without a name', async function () {
|
it('Should fail without a name', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'name')
|
const fields = omit(baseCorrectParams, [ 'name' ])
|
||||||
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -131,7 +127,7 @@ describe('Test video channels API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without a name', async function () {
|
it('Should fail without a name', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'displayName')
|
const fields = omit(baseCorrectParams, [ 'displayName' ])
|
||||||
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
|
||||||
import { omit } from 'lodash'
|
|
||||||
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared'
|
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared'
|
||||||
import { buildAbsoluteFixturePath } from '@shared/core-utils'
|
import { buildAbsoluteFixturePath, omit } from '@shared/core-utils'
|
||||||
import { HttpStatusCode, VideoPrivacy } from '@shared/models'
|
import { HttpStatusCode, VideoPrivacy } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
@ -107,7 +105,7 @@ describe('Test video imports API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without a target url', async function () {
|
it('Should fail without a target url', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'targetUrl')
|
const fields = omit(baseCorrectParams, [ 'targetUrl' ])
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
url: server.url,
|
url: server.url,
|
||||||
path,
|
path,
|
||||||
|
@ -189,7 +187,7 @@ describe('Test video imports API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without a channel', async function () {
|
it('Should fail without a channel', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'channelId')
|
const fields = omit(baseCorrectParams, [ 'channelId' ])
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
})
|
})
|
||||||
|
@ -271,7 +269,7 @@ describe('Test video imports API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid torrent file', async function () {
|
it('Should fail with an invalid torrent file', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'targetUrl')
|
const fields = omit(baseCorrectParams, [ 'targetUrl' ])
|
||||||
const attaches = {
|
const attaches = {
|
||||||
torrentfile: buildAbsoluteFixturePath('avatar-big.png')
|
torrentfile: buildAbsoluteFixturePath('avatar-big.png')
|
||||||
}
|
}
|
||||||
|
@ -280,7 +278,7 @@ describe('Test video imports API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail with an invalid magnet URI', async function () {
|
it('Should fail with an invalid magnet URI', async function () {
|
||||||
let fields = omit(baseCorrectParams, 'targetUrl')
|
let fields = omit(baseCorrectParams, [ 'targetUrl' ])
|
||||||
fields = { ...fields, magnetUri: 'blabla' }
|
fields = { ...fields, magnetUri: 'blabla' }
|
||||||
|
|
||||||
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
|
||||||
|
@ -339,7 +337,7 @@ describe('Test video imports API validator', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let fields = omit(baseCorrectParams, 'targetUrl')
|
let fields = omit(baseCorrectParams, [ 'targetUrl' ])
|
||||||
fields = { ...fields, magnetUri: FIXTURE_URLS.magnet }
|
fields = { ...fields, magnetUri: FIXTURE_URLS.magnet }
|
||||||
|
|
||||||
await makePostBodyRequest({
|
await makePostBodyRequest({
|
||||||
|
@ -350,7 +348,7 @@ describe('Test video imports API validator', function () {
|
||||||
expectedStatus: HttpStatusCode.CONFLICT_409
|
expectedStatus: HttpStatusCode.CONFLICT_409
|
||||||
})
|
})
|
||||||
|
|
||||||
fields = omit(fields, 'magnetUri')
|
fields = omit(fields, [ 'magnetUri' ])
|
||||||
const attaches = {
|
const attaches = {
|
||||||
torrentfile: buildAbsoluteFixturePath('video-720p.torrent')
|
torrentfile: buildAbsoluteFixturePath('video-720p.torrent')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
import { expect } from 'chai'
|
||||||
import * as chai from 'chai'
|
|
||||||
import { omit } from 'lodash'
|
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared'
|
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared'
|
||||||
import { randomInt, root } from '@shared/core-utils'
|
import { omit, randomInt, root } from '@shared/core-utils'
|
||||||
import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
|
import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
@ -18,8 +16,6 @@ import {
|
||||||
setAccessTokensToServers
|
setAccessTokensToServers
|
||||||
} from '@shared/server-commands'
|
} from '@shared/server-commands'
|
||||||
|
|
||||||
const expect = chai.expect
|
|
||||||
|
|
||||||
describe('Test videos API validator', function () {
|
describe('Test videos API validator', function () {
|
||||||
const path = '/api/v1/videos/'
|
const path = '/api/v1/videos/'
|
||||||
let server: PeerTubeServer
|
let server: PeerTubeServer
|
||||||
|
@ -219,7 +215,7 @@ describe('Test videos API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without name', async function () {
|
it('Should fail without name', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'name')
|
const fields = omit(baseCorrectParams, [ 'name' ])
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
|
@ -268,7 +264,7 @@ describe('Test videos API validator', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail without a channel', async function () {
|
it('Should fail without a channel', async function () {
|
||||||
const fields = omit(baseCorrectParams, 'channelId')
|
const fields = omit(baseCorrectParams, [ 'channelId' ])
|
||||||
const attaches = baseCorrectAttaches
|
const attaches = baseCorrectAttaches
|
||||||
|
|
||||||
await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode)
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { orderBy } from 'lodash'
|
|
||||||
import { FIXTURE_URLS } from '@server/tests/shared'
|
import { FIXTURE_URLS } from '@server/tests/shared'
|
||||||
|
import { sortObjectComparator } from '@shared/core-utils'
|
||||||
import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'
|
import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'
|
||||||
import {
|
import {
|
||||||
BlacklistCommand,
|
BlacklistCommand,
|
||||||
|
@ -138,7 +138,7 @@ describe('Test video blacklist', function () {
|
||||||
expect(blacklistedVideos).to.be.an('array')
|
expect(blacklistedVideos).to.be.an('array')
|
||||||
expect(blacklistedVideos.length).to.equal(2)
|
expect(blacklistedVideos.length).to.equal(2)
|
||||||
|
|
||||||
const result = orderBy(body.data, [ 'id' ], [ 'desc' ])
|
const result = [ ...body.data ].sort(sortObjectComparator('id', 'desc'))
|
||||||
expect(blacklistedVideos).to.deep.equal(result)
|
expect(blacklistedVideos).to.deep.equal(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ describe('Test video blacklist', function () {
|
||||||
expect(blacklistedVideos).to.be.an('array')
|
expect(blacklistedVideos).to.be.an('array')
|
||||||
expect(blacklistedVideos.length).to.equal(2)
|
expect(blacklistedVideos.length).to.equal(2)
|
||||||
|
|
||||||
const result = orderBy(body.data, [ 'name' ], [ 'desc' ])
|
const result = [ ...body.data ].sort(sortObjectComparator('name', 'desc'))
|
||||||
expect(blacklistedVideos).to.deep.equal(result)
|
expect(blacklistedVideos).to.deep.equal(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ describe('Test video blacklist', function () {
|
||||||
expect(blacklistedVideos).to.be.an('array')
|
expect(blacklistedVideos).to.be.an('array')
|
||||||
expect(blacklistedVideos.length).to.equal(2)
|
expect(blacklistedVideos.length).to.equal(2)
|
||||||
|
|
||||||
const result = orderBy(body.data, [ 'createdAt' ])
|
const result = [ ...body.data ].sort(sortObjectComparator('createdAt', 'asc'))
|
||||||
expect(blacklistedVideos).to.deep.equal(result)
|
expect(blacklistedVideos).to.deep.equal(result)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
import { expect } from 'chai'
|
||||||
import * as chai from 'chai'
|
|
||||||
import { omit } from 'lodash'
|
|
||||||
import { canDoQuickTranscode } from '@server/helpers/ffmpeg'
|
import { canDoQuickTranscode } from '@server/helpers/ffmpeg'
|
||||||
import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared'
|
import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared'
|
||||||
import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils'
|
import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate, omit } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
buildFileMetadata,
|
buildFileMetadata,
|
||||||
getAudioStream,
|
getAudioStream,
|
||||||
|
@ -26,8 +24,6 @@ import {
|
||||||
webtorrentAdd
|
webtorrentAdd
|
||||||
} from '@shared/server-commands'
|
} from '@shared/server-commands'
|
||||||
|
|
||||||
const expect = chai.expect
|
|
||||||
|
|
||||||
function updateConfigForTranscoding (server: PeerTubeServer) {
|
function updateConfigForTranscoding (server: PeerTubeServer) {
|
||||||
return server.config.updateCustomSubConfig({
|
return server.config.updateCustomSubConfig({
|
||||||
newConfig: {
|
newConfig: {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { omit } from 'lodash'
|
import { omit } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
Account,
|
Account,
|
||||||
HTMLServerConfig,
|
HTMLServerConfig,
|
||||||
|
@ -31,7 +31,7 @@ function checkIndexTags (html: string, title: string, description: string, css:
|
||||||
expect(html).to.contain('<meta name="description" content="' + description + '" />')
|
expect(html).to.contain('<meta name="description" content="' + description + '" />')
|
||||||
expect(html).to.contain('<style class="custom-css-style">' + css + '</style>')
|
expect(html).to.contain('<style class="custom-css-style">' + css + '</style>')
|
||||||
|
|
||||||
const htmlConfig: HTMLServerConfig = omit(config, 'signup')
|
const htmlConfig: HTMLServerConfig = omit(config, [ 'signup' ])
|
||||||
const configObjectString = JSON.stringify(htmlConfig)
|
const configObjectString = JSON.stringify(htmlConfig)
|
||||||
const configEscapedString = JSON.stringify(configObjectString)
|
const configEscapedString = JSON.stringify(configObjectString)
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,19 @@ function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function omit <O extends object, K extends keyof O> (object: O, keys: K[]): Exclude<O, K> {
|
||||||
|
const result: any = {}
|
||||||
|
const keysSet = new Set(keys) as Set<string>
|
||||||
|
|
||||||
|
for (const [ key, value ] of Object.entries(object)) {
|
||||||
|
if (keysSet.has(key)) continue
|
||||||
|
|
||||||
|
result[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
|
function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
|
||||||
return (Object.keys(object) as K[]).filter(k => keys.includes(k))
|
return (Object.keys(object) as K[]).filter(k => keys.includes(k))
|
||||||
}
|
}
|
||||||
|
@ -30,6 +43,7 @@ function sortObjectComparator (key: string, order: 'asc' | 'desc') {
|
||||||
|
|
||||||
export {
|
export {
|
||||||
pick,
|
pick,
|
||||||
|
omit,
|
||||||
getKeys,
|
getKeys,
|
||||||
sortObjectComparator
|
sortObjectComparator
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { omit } from 'lodash'
|
import { omit, pick } from '@shared/core-utils'
|
||||||
import { pick } from '@shared/core-utils'
|
|
||||||
import {
|
import {
|
||||||
HttpStatusCode,
|
HttpStatusCode,
|
||||||
MyUser,
|
MyUser,
|
||||||
|
@ -298,7 +297,7 @@ export class UsersCommand extends AbstractCommand {
|
||||||
updateMe (options: OverrideCommandOptions & UserUpdateMe) {
|
updateMe (options: OverrideCommandOptions & UserUpdateMe) {
|
||||||
const path = '/api/v1/users/me'
|
const path = '/api/v1/users/me'
|
||||||
|
|
||||||
const toSend: UserUpdateMe = omit(options, 'url', 'accessToken')
|
const toSend: UserUpdateMe = omit(options, [ 'expectedStatus', 'token' ])
|
||||||
|
|
||||||
return this.putBodyRequest({
|
return this.putBodyRequest({
|
||||||
...options,
|
...options,
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import { readdir } from 'fs-extra'
|
import { readdir } from 'fs-extra'
|
||||||
import { omit } from 'lodash'
|
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { wait } from '@shared/core-utils'
|
import { omit, wait } from '@shared/core-utils'
|
||||||
import {
|
import {
|
||||||
HttpStatusCode,
|
HttpStatusCode,
|
||||||
LiveVideo,
|
LiveVideo,
|
||||||
|
@ -103,7 +102,7 @@ export class LiveCommand extends AbstractCommand {
|
||||||
|
|
||||||
path,
|
path,
|
||||||
attaches,
|
attaches,
|
||||||
fields: omit(fields, 'thumbnailfile', 'previewfile'),
|
fields: omit(fields, [ 'thumbnailfile', 'previewfile' ]),
|
||||||
implicitToken: true,
|
implicitToken: true,
|
||||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { omit } from 'lodash'
|
import { omit, pick } from '@shared/core-utils'
|
||||||
import { pick } from '@shared/core-utils'
|
|
||||||
import {
|
import {
|
||||||
BooleanBothQuery,
|
BooleanBothQuery,
|
||||||
HttpStatusCode,
|
HttpStatusCode,
|
||||||
|
@ -136,7 +135,7 @@ export class PlaylistsCommand extends AbstractCommand {
|
||||||
}) {
|
}) {
|
||||||
const path = '/api/v1/video-playlists'
|
const path = '/api/v1/video-playlists'
|
||||||
|
|
||||||
const fields = omit(options.attributes, 'thumbnailfile')
|
const fields = omit(options.attributes, [ 'thumbnailfile' ])
|
||||||
|
|
||||||
const attaches = options.attributes.thumbnailfile
|
const attaches = options.attributes.thumbnailfile
|
||||||
? { thumbnailfile: options.attributes.thumbnailfile }
|
? { thumbnailfile: options.attributes.thumbnailfile }
|
||||||
|
@ -161,7 +160,7 @@ export class PlaylistsCommand extends AbstractCommand {
|
||||||
}) {
|
}) {
|
||||||
const path = '/api/v1/video-playlists/' + options.playlistId
|
const path = '/api/v1/video-playlists/' + options.playlistId
|
||||||
|
|
||||||
const fields = omit(options.attributes, 'thumbnailfile')
|
const fields = omit(options.attributes, [ 'thumbnailfile' ])
|
||||||
|
|
||||||
const attaches = options.attributes.thumbnailfile
|
const attaches = options.attributes.thumbnailfile
|
||||||
? { thumbnailfile: options.attributes.thumbnailfile }
|
? { thumbnailfile: options.attributes.thumbnailfile }
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { createReadStream, stat } from 'fs-extra'
|
import { createReadStream, stat } from 'fs-extra'
|
||||||
import got, { Response as GotResponse } from 'got'
|
import got, { Response as GotResponse } from 'got'
|
||||||
import { omit } from 'lodash'
|
|
||||||
import validator from 'validator'
|
import validator from 'validator'
|
||||||
import { buildAbsoluteFixturePath, pick, wait } from '@shared/core-utils'
|
import { buildAbsoluteFixturePath, omit, pick, wait } from '@shared/core-utils'
|
||||||
import { buildUUID } from '@shared/extra-utils'
|
import { buildUUID } from '@shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
HttpStatusCode,
|
HttpStatusCode,
|
||||||
|
@ -484,7 +483,7 @@ export class VideosCommand extends AbstractCommand {
|
||||||
},
|
},
|
||||||
|
|
||||||
// Fixture will be sent later
|
// Fixture will be sent later
|
||||||
attaches: this.buildUploadAttaches(omit(options.attributes, 'fixture')),
|
attaches: this.buildUploadAttaches(omit(options.attributes, [ 'fixture' ])),
|
||||||
implicitToken: true,
|
implicitToken: true,
|
||||||
|
|
||||||
defaultExpectedStatus: null
|
defaultExpectedStatus: null
|
||||||
|
|
Loading…
Reference in New Issue