Fix Windows tests

This commit is contained in:
Daniel Kennedy
2026-02-24 15:14:38 -05:00
parent f724553a92
commit e6eccfcc4b
+16 -19
View File
@@ -39,26 +39,23 @@ describe('createRawFileUploadStream', () => {
}) })
it('should propagate file read errors through the upload stream', async () => { it('should propagate file read errors through the upload stream', async () => {
const unreadableFile = path.join(fixtures.testDirectory, 'unreadable.txt') // Use a directory path — createReadStream on a directory fails cross-platform
fs.writeFileSync(unreadableFile, 'secret') // Mock lstat to return a non-symlink result so we reach createReadStream
fs.chmodSync(unreadableFile, 0o000) const dirPath = fixtures.testDirectory
jest
.spyOn(fs.promises, 'lstat')
.mockResolvedValue({isSymbolicLink: () => false} as fs.Stats)
const uploadStream = await createRawFileUploadStream(unreadableFile) const uploadStream = await createRawFileUploadStream(dirPath)
try { await expect(
await expect( new Promise((resolve, reject) => {
new Promise((resolve, reject) => { uploadStream.on('data', resolve)
uploadStream.on('data', resolve) uploadStream.on('end', resolve)
uploadStream.on('end', resolve) uploadStream.on('error', reject)
uploadStream.on('error', reject) })
}) ).rejects.toThrow(
).rejects.toThrow( 'An error has occurred during file read for the artifact'
'An error has occurred during file read for the artifact' )
)
} finally {
// Restore permissions so cleanup can delete the file
fs.chmodSync(unreadableFile, 0o644)
fs.unlinkSync(unreadableFile)
}
}) })
}) })