Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable composer.lock for --all-projects #976

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const AUTO_DETECTABLE_FILES: string[] = [
'project.assets.json',
'Podfile',
'Podfile.lock',
'composer.lock',
];

// when file is specified with --file, we look it up here
Expand Down
29 changes: 29 additions & 0 deletions test/acceptance/cli-monitor/cli-monitor.all-projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,35 @@ export const AllProjectsTests: AcceptanceTests = {
'Same body for --all-projects and --file=pom.xml',
);
},
'`monitor composer-app with --all-projects and without same meta`': (
params,
utils,
) => async (t) => {
utils.chdirWorkspaces();
const spyPlugin = sinon.spy(params.plugins, 'loadPlugin');
t.teardown(spyPlugin.restore);

await params.cli.monitor('composer-app', {
allProjects: true,
});
// Pop all calls to server and filter out calls to `featureFlag` endpoint
const [composerAll] = params.server
.popRequests(2)
.filter((req) => req.url.includes('/monitor/'));

await params.cli.monitor('composer-app', {
file: 'composer.lock',
});
const [requestsComposer] = params.server
.popRequests(2)
.filter((req) => req.url.includes('/monitor/'));

t.deepEqual(
composerAll.body,
requestsComposer.body,
'Same body for --all-projects and --file=composer.lock',
);
},
'`monitor mono-repo-project with lockfiles --all-projects --json`': (
params,
utils,
Expand Down
31 changes: 31 additions & 0 deletions test/acceptance/cli-test/cli-test.all-projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,5 +440,36 @@ export const AllProjectsTests: AcceptanceTests = {
t.fail('expected to pass');
}
},
'`test composer-app --all-projects`': (params, utils) => async (t) => {
utils.chdirWorkspaces();
const spyPlugin = sinon.spy(params.plugins, 'loadPlugin');
t.teardown(spyPlugin.restore);

const result = await params.cli.test('composer-app', {
allProjects: true,
});

t.ok(spyPlugin.withArgs('composer').calledOnce, 'calls composer plugin');

params.server.popRequests(2).forEach((req) => {
t.equal(req.method, 'POST', 'makes POST request');
t.equal(
req.headers['x-snyk-cli-version'],
params.versionNumber,
'sends version number',
);
t.match(req.url, '/api/v1/test', 'posts to correct url');
});
t.match(
result,
'Package manager: composer',
'contains package manager composer',
);
t.match(
result,
'Target file: composer.lock',
'contains target file composer.lock',
);
},
},
};