2019-11-15 09:45:14 +00:00
|
|
|
import { expect } from 'chai';
|
2019-08-15 12:40:55 +00:00
|
|
|
import { balenaAPIMock, runCommand } from '../../helpers';
|
|
|
|
|
|
|
|
describe('balena env add', function() {
|
|
|
|
it('should successfully add an environment variable', async () => {
|
|
|
|
const deviceId = 'f63fd7d7812c34c4c14ae023fdff05f5';
|
|
|
|
const mock = balenaAPIMock();
|
|
|
|
mock
|
|
|
|
.get(/device/)
|
|
|
|
.reply(201, {
|
|
|
|
d: [
|
|
|
|
{
|
|
|
|
id: 1031543,
|
|
|
|
__metadata: { uri: '/resin/device(@id)?@id=1031543' },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
})
|
|
|
|
.post(/device_environment_variable/)
|
|
|
|
.reply(200, 'OK');
|
|
|
|
|
|
|
|
const { out, err } = await runCommand(`env add TEST 1 -d ${deviceId}`);
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(out.join('')).to.equal('');
|
|
|
|
expect(err.join('')).to.equal('');
|
2019-08-15 12:40:55 +00:00
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
mock.remove();
|
|
|
|
});
|
|
|
|
});
|