mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-04 13:04:09 +00:00
ac96616e4e
* Replace old resin-image-fs with newer balena-image-fs * package.json: Remove resin-image-fs package * package: Install dependencies that work with node14 * Remove resin-image-fs typings * Fix etcher-sdk related types * local/flash: Add unmountOnSuccess, write, direct properties on flash Taken from https://github.com/balena-io-modules/etcher-sdk/blob/master/examples/multi-destination.ts * tests/utils/eol-conversion: Remove ext2fs sample binary Specifically ext2fs/build/Release/bindings.node I removed it because the file doesn't exist * tests/test-data/pkg: Add new expected warnings darwin/linux/windows * os/configure: Remove windows check * local/flash: Check if environment is WSL and show warning message * Get tests to pass with certain Node v14 warning messages * INSTALL-WINDOWS: Remove os configure warning Improve push and logs support for Node.js v14 (bump 'net-keepalive') Resolves: #2200 Resolves: #1990 Change-type: minor Signed-off-by: Marios Balamatsias <mbalamatsias@gmail.com>
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
import { expect } from 'chai';
|
|
import { promises as fs } from 'fs';
|
|
import * as process from 'process';
|
|
import { runCommand } from '../../helpers';
|
|
import { promisify } from 'util';
|
|
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 });
|
|
tmpPath = (await tmpNameAsync()) as string;
|
|
await fs.copyFile('./tests/test-data/dummy.img', tmpPath);
|
|
});
|
|
|
|
afterEach(async () => {
|
|
api.done();
|
|
await fs.unlink(tmpPath);
|
|
});
|
|
|
|
it('should inject a valid config.json file', async () => {
|
|
api.expectGetApplication();
|
|
api.expectGetDeviceTypes();
|
|
api.expectDownloadConfig();
|
|
api.expectApplicationProvisioning();
|
|
|
|
const command: string[] = [
|
|
`os configure ${tmpPath}`,
|
|
'--device-type raspberrypi3',
|
|
'--version 2.47.0+rev1',
|
|
'--application testApp',
|
|
'--config-app-update-poll-interval 10',
|
|
'--config-network ethernet',
|
|
'--initial-device-name testDeviceName',
|
|
];
|
|
|
|
const { err } = await runCommand(command.join(' '));
|
|
expect(err.join('')).to.equal('');
|
|
|
|
// confirm the image contains a config.json...
|
|
const imagefs = await import('balena-image-fs');
|
|
const config = await imagefs.interact(tmpPath, 1, async (_fs) => {
|
|
return await promisify(_fs.readFile)('/config.json');
|
|
});
|
|
expect(config).to.not.be.empty;
|
|
|
|
// confirm the image has the correct config.json values...
|
|
const configObj = JSON.parse(config.toString('utf8'));
|
|
expect(configObj).to.have.property('deviceType', 'raspberrypi3');
|
|
expect(configObj).to.have.property('initialDeviceName', 'testDeviceName');
|
|
});
|
|
});
|
|
}
|