/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
import { checkResolutionsInMasterPlaylist, expectStartWith } from '@server/tests/shared'
-import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { areMockObjectStorageTestsDisabled } from '@shared/core-utils'
import { HttpStatusCode, VideoDetails } from '@shared/models'
import {
cleanupTests,
waitJobs
} from '@shared/server-commands'
-const expect = chai.expect
-
async function checkFilesInObjectStorage (video: VideoDetails) {
for (const file of video.files) {
- expectStartWith(file.fileUrl, ObjectStorageCommand.getWebTorrentBaseUrl())
- await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
+ expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl())
+ await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
}
if (video.streamingPlaylists.length === 0) return
const hlsPlaylist = video.streamingPlaylists[0]
for (const file of hlsPlaylist.files) {
- expectStartWith(file.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl())
- await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
+ expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl())
+ await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
}
- expectStartWith(hlsPlaylist.playlistUrl, ObjectStorageCommand.getPlaylistBaseUrl())
- await makeRawRequest(hlsPlaylist.playlistUrl, HttpStatusCode.OK_200)
+ expectStartWith(hlsPlaylist.playlistUrl, ObjectStorageCommand.getMockPlaylistBaseUrl())
+ await makeRawRequest({ url: hlsPlaylist.playlistUrl, expectedStatus: HttpStatusCode.OK_200 })
- expectStartWith(hlsPlaylist.segmentsSha256Url, ObjectStorageCommand.getPlaylistBaseUrl())
- await makeRawRequest(hlsPlaylist.segmentsSha256Url, HttpStatusCode.OK_200)
+ expectStartWith(hlsPlaylist.segmentsSha256Url, ObjectStorageCommand.getMockPlaylistBaseUrl())
+ await makeRawRequest({ url: hlsPlaylist.segmentsSha256Url, expectedStatus: HttpStatusCode.OK_200 })
}
function runTests (objectStorage: boolean) {
this.timeout(120000)
const config = objectStorage
- ? ObjectStorageCommand.getDefaultConfig()
+ ? ObjectStorageCommand.getDefaultMockConfig()
: {}
// Run server 2 to have transcoding enabled
await doubleFollow(servers[0], servers[1])
- if (objectStorage) await ObjectStorageCommand.prepareDefaultBuckets()
+ if (objectStorage) await ObjectStorageCommand.prepareDefaultMockBuckets()
const { shortUUID } = await servers[0].videos.quickUpload({ name: 'video' })
videoUUID = shortUUID
const resolutions = hlsPlaylist.files.map(f => f.resolution.id)
await checkResolutionsInMasterPlaylist({ server: servers[0], playlistUrl: hlsPlaylist.playlistUrl, resolutions })
- const shaBody = await servers[0].streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url })
+ const shaBody = await servers[0].streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url, withRetry: true })
expect(Object.keys(shaBody)).to.have.lengthOf(5)
}
}
it('Should have correctly deleted previous files', async function () {
for (const fileUrl of shouldBeDeleted) {
- await makeRawRequest(fileUrl, HttpStatusCode.NOT_FOUND_404)
+ await makeRawRequest({ url: fileUrl, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
}
})
})
describe('On object storage', function () {
- if (areObjectStorageTestsDisabled()) return
+ if (areMockObjectStorageTestsDisabled()) return
runTests(true)
})