Fix Windows tests
This commit is contained in:
@@ -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)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user