From 61d6acdeb130a7e2ba14cd684c69b61a32aa6fea Mon Sep 17 00:00:00 2001 From: Vallie Joseph Date: Tue, 9 Apr 2024 18:52:19 +0000 Subject: [PATCH] updating test --- .../__tests__/upload-artifact.test.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/artifact/__tests__/upload-artifact.test.ts b/packages/artifact/__tests__/upload-artifact.test.ts index e90e6160..a6ebcb8f 100644 --- a/packages/artifact/__tests__/upload-artifact.test.ts +++ b/packages/artifact/__tests__/upload-artifact.test.ts @@ -9,7 +9,9 @@ import {uploadArtifact} from '../src/internal/upload/upload-artifact' import {noopLogs} from './common' import {FilesNotFoundError} from '../src/internal/shared/errors' import {BlockBlobClient} from '@azure/storage-blob' -import mockFs from 'mock-fs' +import fs from 'fs' +import {Readable} from 'stream' + describe('upload-artifact', () => { beforeEach(() => { noopLogs() @@ -355,6 +357,16 @@ describe('upload-artifact', () => { it('should throw an error uploading blob chunks get delayed', async () => { const mockDate = new Date('2020-01-01') + jest.mock('fs') + + // Mock fs.createReadStream to return a mock stream + fs.createReadStream = jest.fn().mockImplementation(() => { + const mockStream = new Readable() + mockStream.push('file content') + mockStream.push(null) + return mockStream + }) + jest .spyOn(uploadZipSpecification, 'validateRootDirectory') .mockReturnValue() @@ -374,15 +386,6 @@ describe('upload-artifact', () => { destinationPath: 'dir/file3.txt' } ]) - mockFs({ - '/home/user/files/plz-upload': { - 'file1.txt': 'file1 content', - 'file2.txt': 'file2 content', - dir: { - 'file3.txt': 'file3 content' - } - } - }) jest.spyOn(util, 'getBackendIdsFromToken').mockReturnValue({ workflowRunBackendId: '1234',