Skip to content

Commit

Permalink
feat: allow monitor for go modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Mila Votradovec committed Jun 14, 2019
1 parent 63f4597 commit 4a9149d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/lib/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ export async function monitor(root, meta, info: SingleDepRootResult, targetFile)
policy = await snyk.policy.load(policyLocations, {loose: true});

const packageManager = meta.packageManager;
if (packageManager === 'gomodules') {
throw new Error('Monitoring go.mod files is not supported yet.');
}
analytics.add('packageManager', packageManager);

const target = await projectMetadata.getInfo(pkg);
Expand Down
16 changes: 13 additions & 3 deletions test/acceptance/cli.acceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2497,15 +2497,25 @@ test('`monitor golang-mod --file=go.mod', async (t) => {
};
},
};
sinon.spy(plugin, 'inspect');
const spyPlugin = sinon.spy(plugin, 'inspect');

const loadPlugin = sinon.stub(plugins, 'loadPlugin');
t.teardown(loadPlugin.restore);
loadPlugin.withArgs('gomodules').returns(plugin);

t.rejects(cli.monitor('golang-mod', {
await cli.monitor('golang-mod', {
file: 'go.mod',
}), /is not supported yet/, 'not supported message is shown');
});

const req = server.popRequest();
t.equal(req.method, 'PUT', 'makes PUT request');
t.match(req.url, '/monitor/gomodules', 'puts at correct url');
t.equal(req.body.targetFile, 'go.mod', 'sends the targetFile');
t.same(spyPlugin.getCall(0).args,
['golang-mod', 'go.mod', {
args: null,
file: 'go.mod',
}], 'calls golang plugin');
});

test('`monitor golang-app --file=Gopkg.lock', async (t) => {
Expand Down

0 comments on commit 4a9149d

Please sign in to comment.