Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: Reproducing #2220 in test cases #2609

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion tests/commands/os/configure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const tmpNameAsync = promisify(tmp.tmpName);
import { BalenaAPIMock } from '../../nock/balena-api-mock';

if (process.platform !== 'win32') {
describe('balena os configure', function () {
describe.only('balena os configure', function () {
let api: BalenaAPIMock;
let tmpPath: string;

Expand Down Expand Up @@ -77,5 +77,52 @@ if (process.platform !== 'win32') {
expect(configObj).to.have.property('deviceType', 'raspberrypi3');
expect(configObj).to.have.property('initialDeviceName', 'testDeviceName');
});

it('should inject a valid config.json file on top of an already configured one', async () => {
api.expectGetApplication();
api.expectGetConfigDeviceTypes();
api.expectDownloadConfig();

const command: string[] = [
`os configure ${tmpPath}`,
'--device-type raspberrypi3',
'--version 2.47.0+rev1',
'--fleet testApp',
'--config-app-update-poll-interval 10',
'--config-network ethernet',
'--initial-device-name otherTestDeviceName',
'--provisioning-key-name testKey',
'--provisioning-key-expiry-date 2050-12-12',
];

const { err } = await runCommand(command.join(' '));
expect(err.join('')).to.equal('');
const command2: string[] = [
`os configure ${tmpPath}`,
'--device-type raspberrypi3',
'--version 2.47.0+rev1',
'--fleet testApp',
'--config-app-update-poll-interval 10',
'--config-network ethernet',
'--initial-device-name testDeviceName',
'--provisioning-key-name testKey',
'--provisioning-key-expiry-date 2050-12-12',
];

const { err: err2 } = await runCommand(command2.join(' '));
expect(err2.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');
});
});
}