Compare commits
2 Commits
lite/fix-l
...
gab-test-x
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
715ab283e4 | ||
|
|
f9a65e244c |
@@ -39,6 +39,8 @@
|
|||||||
"fs-extra": "^11.1.1",
|
"fs-extra": "^11.1.1",
|
||||||
"get-stream": "^6.0.0",
|
"get-stream": "^6.0.0",
|
||||||
"rimraf": "^4.1.1",
|
"rimraf": "^4.1.1",
|
||||||
|
"sinon": "^15.0.4",
|
||||||
|
"test": "^3.3.0",
|
||||||
"tmp": "^0.2.1"
|
"tmp": "^0.2.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -48,7 +50,9 @@
|
|||||||
"prebuild": "yarn run clean",
|
"prebuild": "yarn run clean",
|
||||||
"predev": "yarn run clean",
|
"predev": "yarn run clean",
|
||||||
"prepublishOnly": "yarn run build",
|
"prepublishOnly": "yarn run build",
|
||||||
"postversion": "npm publish"
|
"pretest-integration": "yarn run build",
|
||||||
|
"postversion": "npm publish",
|
||||||
|
"test-integration": "node--test ./dist/*.integ.js"
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Vates SAS",
|
"name": "Vates SAS",
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
/* eslint-env jest */
|
import { afterEach, beforeEach, test } from 'test'
|
||||||
|
import sinon from 'sinon'
|
||||||
|
|
||||||
import { spawn } from 'child_process'
|
import { spawn } from 'child_process'
|
||||||
import { createReadStream, createWriteStream, readFile } from 'fs-extra'
|
import { createReadStream, createWriteStream, readFile } from 'fs-extra'
|
||||||
import execa from 'execa'
|
import execa from 'execa'
|
||||||
@@ -10,7 +12,8 @@ import { writeOvaOn } from './ova-generate'
|
|||||||
import { parseOVF } from './ova-read'
|
import { parseOVF } from './ova-read'
|
||||||
|
|
||||||
const initialDir = process.cwd()
|
const initialDir = process.cwd()
|
||||||
jest.setTimeout(100000)
|
const clock = sinon.useFakeTimers()
|
||||||
|
clock.tick(100000)
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const dir = await pFromCallback(cb => tmp.dir(cb))
|
const dir = await pFromCallback(cb => tmp.dir(cb))
|
||||||
process.chdir(dir)
|
process.chdir(dir)
|
||||||
@@ -99,7 +102,7 @@ test('An ova file is generated correctly', async () => {
|
|||||||
try {
|
try {
|
||||||
await execXmllint(xml, [
|
await execXmllint(xml, [
|
||||||
'--schema',
|
'--schema',
|
||||||
path.join(__dirname, 'ova-schema', 'dsp8023_1.1.1.xsd'),
|
path.join(__dirname, '../src/ova-schema', 'dsp8023_1.1.1.xsd'),
|
||||||
'--noout',
|
'--noout',
|
||||||
'--nonet',
|
'--nonet',
|
||||||
'-',
|
'-',
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
/* eslint-env jest */
|
import { afterEach, beforeEach, test } from 'test'
|
||||||
|
import { strict as assert } from 'assert'
|
||||||
|
|
||||||
import { exec } from 'child-process-promise'
|
import { exec } from 'child-process-promise'
|
||||||
import { createReadStream } from 'fs'
|
import { createReadStream } from 'fs'
|
||||||
@@ -66,14 +67,14 @@ test('An ova file is parsed correctly', async () => {
|
|||||||
const directGrainTableFetch = await readVmdkGrainTable(async (start, end) =>
|
const directGrainTableFetch = await readVmdkGrainTable(async (start, end) =>
|
||||||
vmdkParsableFile.slice(start, end).read()
|
vmdkParsableFile.slice(start, end).read()
|
||||||
)
|
)
|
||||||
expect(directGrainTableFetch).toEqual(expectedResult.tables[vmdkFileName])
|
assert.deepEqual(directGrainTableFetch, expectedResult.tables[vmdkFileName])
|
||||||
const data = await parseOVAFile(new NodeParsableFile(ovaName), (buffer, encoder) => {
|
const data = await parseOVAFile(new NodeParsableFile(ovaName), (buffer, encoder) => {
|
||||||
return Buffer.from(buffer).toString(encoder)
|
return Buffer.from(buffer).toString(encoder)
|
||||||
})
|
})
|
||||||
for (const fileName in data.tables) {
|
for (const fileName in data.tables) {
|
||||||
data.tables[fileName] = await data.tables[fileName]
|
data.tables[fileName] = await data.tables[fileName]
|
||||||
}
|
}
|
||||||
expect(data).toEqual(expectedResult)
|
assert.deepEqual(data, expectedResult)
|
||||||
})
|
})
|
||||||
|
|
||||||
function arrayToBuffer(array) {
|
function arrayToBuffer(array) {
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
/* eslint-env jest */
|
import { afterEach, beforeEach, test } from 'test'
|
||||||
|
import { strict as assert } from 'assert'
|
||||||
|
|
||||||
import { createReadStream, readFile } from 'fs-extra'
|
import { createReadStream, readFile } from 'fs-extra'
|
||||||
import { exec } from 'child-process-promise'
|
import { exec } from 'child-process-promise'
|
||||||
@@ -28,5 +29,5 @@ test('Virtual Buffer can read a file correctly', async () => {
|
|||||||
const part1 = await buffer.readChunk(10)
|
const part1 = await buffer.readChunk(10)
|
||||||
const part2 = await buffer.readChunk(1038)
|
const part2 = await buffer.readChunk(1038)
|
||||||
const original = await readFile(rawFileName)
|
const original = await readFile(rawFileName)
|
||||||
expect(Buffer.concat([part1, part2]).toString('ascii')).toEqual(original.toString('ascii'))
|
assert.equal(Buffer.concat([part1, part2]).toString('ascii'), original.toString('ascii'))
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
/* eslint-env jest */
|
import { afterEach, beforeEach, test } from 'test'
|
||||||
|
import { strict as assert } from 'assert'
|
||||||
|
import sinon from 'sinon'
|
||||||
|
|
||||||
import { createReadStream, stat } from 'fs-extra'
|
import { createReadStream, stat } from 'fs-extra'
|
||||||
import { exec } from 'child-process-promise'
|
import { exec } from 'child-process-promise'
|
||||||
@@ -34,7 +36,8 @@ function bufferToArray(buffer) {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
jest.setTimeout(10000)
|
const clock = sinon.useFakeTimers()
|
||||||
|
clock.tick(10000)
|
||||||
|
|
||||||
const initialDir = process.cwd()
|
const initialDir = process.cwd()
|
||||||
|
|
||||||
@@ -67,8 +70,8 @@ test('VMDKDirectParser reads OK', async () => {
|
|||||||
for await (const res of parser.blockIterator()) {
|
for await (const res of parser.blockIterator()) {
|
||||||
harvested.push(res)
|
harvested.push(res)
|
||||||
}
|
}
|
||||||
expect(harvested.length).toEqual(2)
|
assert.equal(harvested.length, 2)
|
||||||
expect(harvested[0].logicalAddressBytes).toEqual(0)
|
assert.equal(harvested[0].logicalAddressBytes, 0)
|
||||||
expect(harvested[0].data.length).toEqual(header.grainSizeSectors * 512)
|
assert.equal(harvested[0].data.length, header.grainSizeSectors * 512)
|
||||||
expect(harvested[1].logicalAddressBytes).toEqual(header.grainSizeSectors * 512)
|
assert.equal(harvested[1].logicalAddressBytes, header.grainSizeSectors * 512)
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
/* eslint-env jest */
|
import { afterEach, beforeEach, test } from 'test'
|
||||||
|
import { strict as assert } from 'assert'
|
||||||
|
import sinon from 'sinon'
|
||||||
|
|
||||||
import execa from 'execa'
|
import execa from 'execa'
|
||||||
import fromEvent from 'promise-toolbox/fromEvent'
|
import fromEvent from 'promise-toolbox/fromEvent'
|
||||||
@@ -15,7 +17,8 @@ import asyncIteratorToStream from 'async-iterator-to-stream'
|
|||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
|
||||||
const initialDir = process.cwd()
|
const initialDir = process.cwd()
|
||||||
jest.setTimeout(100000)
|
const clock = sinon.useFakeTimers()
|
||||||
|
clock.tick(100000)
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const dir = await pFromCallback(cb => tmp.dir(cb))
|
const dir = await pFromCallback(cb => tmp.dir(cb))
|
||||||
@@ -124,7 +127,7 @@ test('Can generate a small VMDK file', async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const data = await readVmdkGrainTable(createFileAccessor(fileName))
|
const data = await readVmdkGrainTable(createFileAccessor(fileName))
|
||||||
expect(bufferToArray(data.grainLogicalAddressList)).toEqual(expectedLBAs)
|
assert.deepEqual(bufferToArray(data.grainLogicalAddressList), expectedLBAs)
|
||||||
const grainFileOffsetList = bufferToArray(data.grainFileOffsetList)
|
const grainFileOffsetList = bufferToArray(data.grainFileOffsetList)
|
||||||
const parser = new VMDKDirectParser(
|
const parser = new VMDKDirectParser(
|
||||||
createReadStream(fileName),
|
createReadStream(fileName),
|
||||||
@@ -142,8 +145,8 @@ test('Can generate a small VMDK file', async () => {
|
|||||||
}
|
}
|
||||||
const resultBuffer = Buffer.concat(resBuffers)
|
const resultBuffer = Buffer.concat(resBuffers)
|
||||||
const startingBuffer = Buffer.concat([b1, b2])
|
const startingBuffer = Buffer.concat([b1, b2])
|
||||||
expect(resultBuffer).toEqual(startingBuffer)
|
assert.deepEqual(resultBuffer, startingBuffer)
|
||||||
expect(resLbas).toEqual(expectedLBAs)
|
assert.deepEqual(resLbas, expectedLBAs)
|
||||||
|
|
||||||
await execa('qemu-img', ['check', 'result.vmdk'])
|
await execa('qemu-img', ['check', 'result.vmdk'])
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user