mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-20 09:26:42 +00:00
Hide discontinued device types in balena app create
.
Add basic tests for `balena app create` Connects-to: #1485 Change-type: patch Signed-off-by: Scott Lowe <scott@balena.io>
This commit is contained in:
parent
afd97bd304
commit
cf42dca777
@ -130,7 +130,9 @@ export function selectDeviceType() {
|
||||
return getBalenaSdk()
|
||||
.models.config.getDeviceTypes()
|
||||
.then(deviceTypes => {
|
||||
deviceTypes = _.sortBy(deviceTypes, 'name');
|
||||
deviceTypes = _.sortBy(deviceTypes, 'name').filter(
|
||||
dt => dt.state !== 'DISCONTINUED',
|
||||
);
|
||||
return getForm().ask({
|
||||
message: 'Device Type',
|
||||
type: 'list',
|
||||
|
35
tests/commands/app/create.spec.ts
Normal file
35
tests/commands/app/create.spec.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { expect } from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import { cleanOutput, runCommand } from '../../helpers';
|
||||
|
||||
const HELP_MESSAGE = `
|
||||
Usage: app create <name>
|
||||
|
||||
Use this command to create a new balena application.
|
||||
|
||||
You can specify the application device type with the \`--type\` option.
|
||||
Otherwise, an interactive dropdown will be shown for you to select from.
|
||||
|
||||
You can see a list of supported device types with
|
||||
|
||||
\t$ balena devices supported
|
||||
|
||||
Examples:
|
||||
|
||||
\t$ balena app create MyApp
|
||||
\t$ balena app create MyApp --type raspberry-pi
|
||||
|
||||
Options:
|
||||
|
||||
--type, -t <type> application device type (Check available types with \`balena devices supported\`)
|
||||
`;
|
||||
|
||||
describe('balena app create', function() {
|
||||
it('should print help text with the -h flag', async () => {
|
||||
const { out, err } = await runCommand('app create -h');
|
||||
|
||||
expect(cleanOutput(out)).to.deep.equal(cleanOutput([HELP_MESSAGE]));
|
||||
|
||||
expect(err).to.have.lengthOf(0);
|
||||
});
|
||||
});
|
@ -1,6 +1,6 @@
|
||||
import { expect } from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import { runCommand } from '../../helpers';
|
||||
import { cleanOutput, runCommand } from '../../helpers';
|
||||
|
||||
const HELP = `
|
||||
Usage: devices supported
|
||||
@ -12,18 +12,6 @@ Examples:
|
||||
\t$ balena devices supported
|
||||
`;
|
||||
|
||||
const cleanOutput = (output: string[] | string) => {
|
||||
return _(_.castArray(output))
|
||||
.map(log => {
|
||||
return log.split('\n').map(line => {
|
||||
return line.trim();
|
||||
});
|
||||
})
|
||||
.flatten()
|
||||
.compact()
|
||||
.value();
|
||||
};
|
||||
|
||||
describe('balena devices supported', function() {
|
||||
it('should list currently supported devices', async () => {
|
||||
const { out, err } = await runCommand('devices supported');
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
import intercept = require('intercept-stdout');
|
||||
import * as _ from 'lodash';
|
||||
import * as nock from 'nock';
|
||||
import * as path from 'path';
|
||||
|
||||
@ -78,3 +79,15 @@ export const balenaAPIMock = () => {
|
||||
configVarSchema: [],
|
||||
});
|
||||
};
|
||||
|
||||
export function cleanOutput(output: string[] | string) {
|
||||
return _(_.castArray(output))
|
||||
.map(log => {
|
||||
return log.split('\n').map(line => {
|
||||
return line.trim();
|
||||
});
|
||||
})
|
||||
.flatten()
|
||||
.compact()
|
||||
.value();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user