Skip to content

Commit

Permalink
fix: meta summary: print actual pkg-manager
Browse files Browse the repository at this point in the history
rather than the package-type, if exist
  • Loading branch information
michael-go authored and odinn1984 committed Dec 18, 2017
1 parent 761b49f commit 60c5f7a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cli/commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ function test(path, options) {
function metaForDisplay(res, options) {
const meta = [
chalk.bold('Organisation: ') + res.org,
chalk.bold('Package manager: ') + res.packageManager,
chalk.bold('Package manager: ') +
(options.packageManager || res.packageManager),
chalk.bold('Target file: ') + options.file,
chalk.bold('Open source: ') + (res.isPrivate ? 'no' : 'yes'),
];
Expand Down
29 changes: 26 additions & 3 deletions test/acceptance/cli.acceptance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function (t) {
});
});

test('`test returns correct meta', function (t) {
test('`test ruby-app` returns correct meta', function (t) {
chdirWorkspaces();
return cli.test('ruby-app')
.then(function (res) {
Expand All @@ -142,7 +142,30 @@ test('`test returns correct meta', function (t) {
});
});

test('`test returns correct meta for a vulnerable result', function (t) {
test('`test gradle-app` returns correct meta', function (t) {
chdirWorkspaces();
var plugin = {
inspect: function () {
return Promise.resolve({package: {}});
},
};
sinon.spy(plugin, 'inspect');
sinon.stub(plugins, 'loadPlugin');
t.teardown(plugins.loadPlugin.restore);
plugins.loadPlugin.withArgs('gradle').returns(plugin);

return cli.test('gradle-app')
.then(function (res) {
var meta = res.slice(res.indexOf('Organisation:')).split('\n');
t.equal(meta[0], 'Organisation: test-org', 'organisation displayed');
t.equal(meta[1], 'Package manager: gradle',
'package manager displayed');
t.equal(meta[2], 'Target file: build.gradle', 'target file displayed');
t.equal(meta[3], 'Open source: no', 'open source displayed');
});
});

test('`test` returns correct meta for a vulnerable result', function (t) {
chdirWorkspaces();
return cli.test('ruby-app', { org: 'org-with-vulns' })
.catch(function (res) {
Expand All @@ -156,7 +179,7 @@ test('`test returns correct meta for a vulnerable result', function (t) {
});
});

test('`test returns correct meta when target file specified', function (t) {
test('`test` returns correct meta when target file specified', function (t) {
chdirWorkspaces();
return cli.test('ruby-app', {file: 'Gemfile.lock'})
.then(function (res) {
Expand Down

0 comments on commit 60c5f7a

Please sign in to comment.