mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-23 15:32:22 +00:00
Merge pull request #1968 from balena-io/tests-reliability
Tests: improve reliability of os/configure.spec.ts
This commit is contained in:
commit
cd3fa4521c
@ -2,23 +2,30 @@ import { expect } from 'chai';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as process from 'process';
|
||||
import { runCommand } from '../../helpers';
|
||||
import { promisify } from 'bluebird';
|
||||
import * as tmp from 'tmp';
|
||||
|
||||
tmp.setGracefulCleanup();
|
||||
const tmpNameAsync = promisify(tmp.tmpName);
|
||||
|
||||
import { BalenaAPIMock } from '../../balena-api-mock';
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
describe('balena os configure', function () {
|
||||
let api: BalenaAPIMock;
|
||||
let tmpPath: string;
|
||||
|
||||
beforeEach(async () => {
|
||||
api = new BalenaAPIMock();
|
||||
api.expectGetWhoAmI({ optional: true, persist: true });
|
||||
api.expectGetMixpanel({ optional: true });
|
||||
await fs.copyFile('./tests/test-data/dummy.img', '/tmp/dummy.img');
|
||||
tmpPath = (await tmpNameAsync()) as string;
|
||||
await fs.copyFile('./tests/test-data/dummy.img', tmpPath);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
api.done();
|
||||
await fs.unlink('/tmp/dummy.img');
|
||||
await fs.unlink(tmpPath);
|
||||
});
|
||||
|
||||
it('should inject a valid config.json file', async () => {
|
||||
@ -28,7 +35,7 @@ if (process.platform !== 'win32') {
|
||||
api.expectApplicationProvisioning();
|
||||
|
||||
const command: string[] = [
|
||||
'os configure /tmp/dummy.img',
|
||||
`os configure ${tmpPath}`,
|
||||
'--device-type raspberrypi3',
|
||||
'--version 2.47.0+rev1',
|
||||
'--application testApp',
|
||||
@ -43,7 +50,7 @@ if (process.platform !== 'win32') {
|
||||
// confirm the image contains a config.json...
|
||||
const imagefs = await require('resin-image-fs');
|
||||
const config = await imagefs.readFile({
|
||||
image: '/tmp/dummy.img',
|
||||
image: tmpPath,
|
||||
partition: 1,
|
||||
path: '/config.json',
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user