2020-01-15 19:41:47 +00:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright 2019-2020 Balena Ltd.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-12-11 12:18:58 +00:00
|
|
|
import { expect } from 'chai';
|
2021-06-25 23:42:07 +00:00
|
|
|
import { BalenaAPIMock } from '../../nock/balena-api-mock';
|
2019-12-11 12:18:58 +00:00
|
|
|
import { cleanOutput, runCommand } from '../../helpers';
|
|
|
|
|
2020-06-15 22:53:07 +00:00
|
|
|
describe('balena device move', function () {
|
2019-12-11 12:18:58 +00:00
|
|
|
let api: BalenaAPIMock;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
api = new BalenaAPIMock();
|
2020-07-09 14:39:33 +00:00
|
|
|
api.expectGetWhoAmI({ optional: true, persist: true });
|
|
|
|
api.expectGetMixpanel({ optional: true });
|
2019-12-11 12:18:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
// Check all expected api calls have been made and clean up.
|
|
|
|
api.done();
|
|
|
|
});
|
|
|
|
|
2020-06-17 13:46:25 +00:00
|
|
|
it('should error if uuid not provided', async () => {
|
2019-12-11 12:18:58 +00:00
|
|
|
const { out, err } = await runCommand('device move');
|
|
|
|
const errLines = cleanOutput(err);
|
|
|
|
|
2020-06-17 13:46:25 +00:00
|
|
|
expect(errLines[0]).to.equal('Missing 1 required argument:');
|
2020-07-15 14:26:31 +00:00
|
|
|
expect(errLines[1]).to.equal(
|
|
|
|
'uuid : comma-separated list (no blank spaces) of device UUIDs to be moved',
|
|
|
|
);
|
2019-12-11 12:18:58 +00:00
|
|
|
expect(out).to.eql([]);
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: Test to add once nock matching issues resolved:
|
|
|
|
// - 'should perform device move if application name provided'
|
|
|
|
// - 'should start interactive selection of application name if none provided'
|
|
|
|
// - 'correctly handles devices with missing application'
|
|
|
|
});
|