2020-07-10 15:09:32 +00:00
|
|
|
import {
|
|
|
|
DownloadOptions,
|
|
|
|
UploadOptions,
|
|
|
|
getDownloadOptions,
|
|
|
|
getUploadOptions
|
|
|
|
} from '../src/options'
|
|
|
|
|
|
|
|
const useAzureSdk = true
|
|
|
|
const downloadConcurrency = 8
|
|
|
|
const timeoutInMs = 30000
|
2022-08-05 05:44:59 +00:00
|
|
|
const abortTimeInMs = 3600000
|
2020-07-10 15:09:32 +00:00
|
|
|
const uploadConcurrency = 4
|
|
|
|
const uploadChunkSize = 32 * 1024 * 1024
|
|
|
|
|
|
|
|
test('getDownloadOptions sets defaults', async () => {
|
|
|
|
const actualOptions = getDownloadOptions()
|
|
|
|
|
|
|
|
expect(actualOptions).toEqual({
|
|
|
|
useAzureSdk,
|
|
|
|
downloadConcurrency,
|
2022-08-03 13:25:47 +00:00
|
|
|
timeoutInMs,
|
|
|
|
abortTimeInMs
|
2020-07-10 15:09:32 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test('getDownloadOptions overrides all settings', async () => {
|
|
|
|
const expectedOptions: DownloadOptions = {
|
|
|
|
useAzureSdk: false,
|
|
|
|
downloadConcurrency: 14,
|
2022-08-03 13:25:47 +00:00
|
|
|
timeoutInMs: 20000,
|
2022-08-05 05:44:59 +00:00
|
|
|
abortTimeInMs: 3600000
|
2020-07-10 15:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const actualOptions = getDownloadOptions(expectedOptions)
|
|
|
|
|
|
|
|
expect(actualOptions).toEqual(expectedOptions)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('getUploadOptions sets defaults', async () => {
|
|
|
|
const actualOptions = getUploadOptions()
|
|
|
|
|
|
|
|
expect(actualOptions).toEqual({
|
|
|
|
uploadConcurrency,
|
|
|
|
uploadChunkSize
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test('getUploadOptions overrides all settings', async () => {
|
|
|
|
const expectedOptions: UploadOptions = {
|
|
|
|
uploadConcurrency: 2,
|
|
|
|
uploadChunkSize: 16 * 1024 * 1024
|
|
|
|
}
|
|
|
|
|
|
|
|
const actualOptions = getUploadOptions(expectedOptions)
|
|
|
|
|
|
|
|
expect(actualOptions).toEqual(expectedOptions)
|
|
|
|
})
|