Commit 77a7dbde authored by Steve Abrams's avatar Steve Abrams Committed by Nicolò Maria Mezzopera

Fix Composer package installation code block

parent fd46e8ce
......@@ -110,6 +110,6 @@ export const composerRegistryInclude = ({ composerPath }) => {
return JSON.stringify(base);
};
export const composerPackageInclude = ({ packageEntity }) => {
const base = { package_name: packageEntity.name };
const base = { [packageEntity.name]: packageEntity.version };
return JSON.stringify(base);
};
---
title: Fix Composer installation code snippet to include package name and version
merge_request: 39400
author:
type: fixed
......@@ -13,6 +13,8 @@ import {
nugetSetupCommand,
pypiPipCommand,
pypiSetupCommand,
composerRegistryInclude,
composerPackageInclude,
} from '~/packages/details/store/getters';
import {
conanPackage,
......@@ -68,6 +70,10 @@ describe('Getters PackageDetails Store', () => {
const nugetSetupCommandStr = `nuget source Add -Name "GitLab" -Source "${registryUrl}" -UserName <your_username> -Password <your_token>`;
const pypiPipCommandStr = `pip install ${pypiPackage.name} --index-url ${registryUrl}`;
const composerRegistryIncludeStr = '{"type":"composer","url":"foo"}';
const composerPackageIncludeStr = JSON.stringify({
[packageWithoutBuildInfo.name]: packageWithoutBuildInfo.version,
});
describe('packagePipeline', () => {
it('should return the pipeline info when pipeline exists', () => {
......@@ -214,4 +220,18 @@ describe('Getters PackageDetails Store', () => {
expect(pypiSetupCommand(state)).toBe(pypiSetupCommandStr);
});
});
describe('composer string getters', () => {
it('gets the correct composerRegistryInclude command', () => {
setupState({ composerPath: 'foo' });
expect(composerRegistryInclude(state)).toBe(composerRegistryIncludeStr);
});
it('gets the correct composerPackageInclude command', () => {
setupState();
expect(composerPackageInclude(state)).toBe(composerPackageIncludeStr);
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment