use unlink and move test file

This commit is contained in:
ggunullu
2023-02-06 10:48:30 +01:00
committed by florent Beauchamp
parent b132ff4fd0
commit 724195d66d
3 changed files with 5 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ const tmp = require('tmp')
const { getSyncedHandler } = require('@xen-orchestra/fs')
const { pFromCallback } = require('promise-toolbox')
const { checkFile, createRandomFile, convertFromRawToVhd } = require('./tests/utils')
const { checkFile, createRandomFile, convertFromRawToVhd } = require('./utils')
let tempDir = null
let disposeHandler

View File

@@ -5,6 +5,7 @@ const { pipeline } = require('readable-stream')
const asyncIteratorToStream = require('async-iterator-to-stream')
const execa = require('execa')
const fs = require('fs-extra')
const fsPromise = require('node:fs/promises')
const { randomBytes } = require('crypto')
const createRandomStream = asyncIteratorToStream(function* (size) {
@@ -25,7 +26,7 @@ async function checkFile(vhdName) {
// 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 fs.rm('outputFile.qcow2')
await fsPromise.unlink('./outputFile.qcow2')
}
exports.checkFile = checkFile

View File

@@ -1,5 +1,5 @@
import execa from 'execa'
import fs from 'fs-extra'
import fs from 'node:fs/promises'
export function suppressUnhandledRejection(p) {
p.catch(Function.prototype)
@@ -11,5 +11,5 @@ export async function checkFile(vhdName) {
// 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 fs.rm('outputFile.qcow2')
await fs.unlink('./outputFile.qcow2')
}