fix(vhd-lib/test): collision during tests (#7062)

multiple tests use the same temporary files
This commit is contained in:
Florent BEAUCHAMP
2023-09-28 16:49:00 +02:00
committed by GitHub
parent 2e1abad255
commit 2ba81d55f8
2 changed files with 11 additions and 2 deletions

View File

@@ -32,6 +32,7 @@
<!--packages-start-->
- @xen-orchestra/xapi minor
- vhd-lib patch
- xo-server-backup-reports patch
- xo-server patch
- xo-web patch

View File

@@ -25,8 +25,16 @@ async function checkFile(vhdName) {
// Since the qemu-img check command isn't compatible with vhd format, we use
// the convert command to do a check by conversion. Indeed, the conversion will
// fail if the source file isn't a proper vhd format.
await execa('qemu-img', ['convert', '-fvpc', '-Oqcow2', vhdName, 'outputFile.qcow2'])
await fsPromise.unlink('./outputFile.qcow2')
const target = vhdName + '.qcow2'
try {
await execa('qemu-img', ['convert', '-fvpc', '-Oqcow2', vhdName, target])
} finally {
try {
await fsPromise.unlink(target)
} catch (err) {
console.warn(err)
}
}
}
exports.checkFile = checkFile