1
0
Fork 0

Fix tests

pull/1882/head
Bassem Dghaidi 2024-12-02 04:18:46 -08:00 committed by GitHub
parent a762876d6d
commit 87171e29ca
2 changed files with 27 additions and 46 deletions

View File

@ -138,7 +138,9 @@ test('save cache fails if a signedUploadURL was not passed', async () => {
const key = 'Linux-node-bb828da54c148048dd17899ba9fda624811cfb43' const key = 'Linux-node-bb828da54c148048dd17899ba9fda624811cfb43'
const cachePaths = [path.resolve(paths)] const cachePaths = [path.resolve(paths)]
const signedUploadURL = '' const signedUploadURL = ''
const archiveFileSize = 1024
const options: UploadOptions = { const options: UploadOptions = {
archiveSizeBytes: archiveFileSize, // These should always match
useAzureSdk: true, useAzureSdk: true,
uploadChunkSize: 64 * 1024 * 1024, uploadChunkSize: 64 * 1024 * 1024,
uploadConcurrency: 8 uploadConcurrency: 8
@ -159,7 +161,6 @@ test('save cache fails if a signedUploadURL was not passed', async () => {
.mockReturnValueOnce(Promise.resolve(compression)) .mockReturnValueOnce(Promise.resolve(compression))
const cacheVersion = cacheUtils.getCacheVersion([paths], compression) const cacheVersion = cacheUtils.getCacheVersion([paths], compression)
const archiveFileSize = 1024
jest jest
.spyOn(cacheUtils, 'getArchiveFileSizeInBytes') .spyOn(cacheUtils, 'getArchiveFileSizeInBytes')
.mockReturnValueOnce(archiveFileSize) .mockReturnValueOnce(archiveFileSize)
@ -195,7 +196,9 @@ test('finalize save cache failure', async () => {
const cachePaths = [path.resolve(paths)] const cachePaths = [path.resolve(paths)]
const logWarningMock = jest.spyOn(core, 'warning') const logWarningMock = jest.spyOn(core, 'warning')
const signedUploadURL = 'https://blob-storage.local?signed=true' const signedUploadURL = 'https://blob-storage.local?signed=true'
const archiveFileSize = 1024
const options: UploadOptions = { const options: UploadOptions = {
archiveSizeBytes: archiveFileSize, // These should always match
useAzureSdk: true, useAzureSdk: true,
uploadChunkSize: 64 * 1024 * 1024, uploadChunkSize: 64 * 1024 * 1024,
uploadConcurrency: 8 uploadConcurrency: 8
@ -218,7 +221,6 @@ test('finalize save cache failure', async () => {
.mockReturnValueOnce(Promise.resolve(compression)) .mockReturnValueOnce(Promise.resolve(compression))
const cacheVersion = cacheUtils.getCacheVersion([paths], compression) const cacheVersion = cacheUtils.getCacheVersion([paths], compression)
const archiveFileSize = 1024
jest jest
.spyOn(cacheUtils, 'getArchiveFileSizeInBytes') .spyOn(cacheUtils, 'getArchiveFileSizeInBytes')
.mockReturnValueOnce(archiveFileSize) .mockReturnValueOnce(archiveFileSize)
@ -268,13 +270,14 @@ test('save with valid inputs uploads a cache', async () => {
const cachePaths = [path.resolve(paths)] const cachePaths = [path.resolve(paths)]
const signedUploadURL = 'https://blob-storage.local?signed=true' const signedUploadURL = 'https://blob-storage.local?signed=true'
const createTarMock = jest.spyOn(tar, 'createTar') const createTarMock = jest.spyOn(tar, 'createTar')
const archiveFileSize = 1024
const options: UploadOptions = { const options: UploadOptions = {
archiveSizeBytes: archiveFileSize, // These should always match
useAzureSdk: true, useAzureSdk: true,
uploadChunkSize: 64 * 1024 * 1024, uploadChunkSize: 64 * 1024 * 1024,
uploadConcurrency: 8 uploadConcurrency: 8
} }
const archiveFileSize = 1024
jest jest
.spyOn(cacheUtils, 'getArchiveFileSizeInBytes') .spyOn(cacheUtils, 'getArchiveFileSizeInBytes')
.mockReturnValueOnce(archiveFileSize) .mockReturnValueOnce(archiveFileSize)

View File

@ -56,25 +56,3 @@ test('upload progress tracked correctly', () => {
expect(progress.getTransferredBytes()).toBe(1000) expect(progress.getTransferredBytes()).toBe(1000)
expect(progress.isDone()).toBe(true) expect(progress.isDone()).toBe(true)
}) })
// test('upload to azure blob storage is successful', () => {
// const archivePath = 'path/to/archive.tzst'
// const signedUploadURL = 'https://storage10.blob.core.windows.net/cache-container/3fe-60?se=2024-12-002T11%3A08%3A58Z&sv=2024-11-04'
// const options: UploadOptions = {
// useAzureSdk: true,
// uploadChunkSize: 64 * 1024 * 1024,
// uploadConcurrency: 8
// }
// jest.spyOn(uploadUtils.UploadProgress.prototype, 'onProgress').mockImplementation(() => (progress: TransferProgressEvent) => {
// return progress.loadedBytes
// })
// jest.spyOn(uploadUtils.UploadProgress.prototype, 'onProgress').mockImplementation(() => (progress: TransferProgressEvent) => {
// return progress.loadedBytes
// })
// const response = uploadUtils.uploadCacheArchiveSDK(signedUploadURL, archivePath, options)
// expect(response).toBeInstanceOf(Promise)
// })