Merge pull request #2684 from laardee/fix-endpoints-info

Fixes info plugin endpoint path issue
This commit is contained in:
Philipp Muens 2016-11-10 10:42:26 +01:00 committed by GitHub
commit 5282bbf2ac
2 changed files with 68 additions and 3 deletions

View File

@ -177,8 +177,8 @@ ${chalk.yellow('region:')} ${info.region}`;
method = event.http.split(' ')[0].toUpperCase();
path = event.http.split(' ')[1];
}
endpointsMessage = endpointsMessage.concat(`\n ${method} - ${info.endpoint}/${path}`);
path = path !== '/' ? `/${path.split('/').filter(p => p !== '').join('/')}` : '';
endpointsMessage = endpointsMessage.concat(`\n ${method} - ${info.endpoint}${path}`);
}
});
});

View File

@ -387,7 +387,72 @@ ${chalk.yellow('functions:')}
expect(awsInfo.display(data)).to.equal(expectedMessage);
});
it("should display only general information when stack doesn't exist", () => {
it('should format information message correctly with slashed endpoint events', () => {
serverless.cli = new CLI(serverless);
const additionalEvents = [
{
http: {
path: '/',
method: 'POST',
},
},
{
http: {
path: '/both/',
method: 'POST',
},
},
{
http: {
path: '/both/add/',
method: 'POST',
},
},
{
http: {
path: 'e',
method: 'POST',
},
},
];
serverless.service.functions = {
function1: {
events: additionalEvents,
},
};
sinon.stub(serverless.cli, 'consoleLog').returns();
const data = {
info: {
service: 'my-first',
stage: 'dev',
region: 'eu-west-1',
endpoint: 'ab12cd34ef.execute-api.us-east-1.amazonaws.com/dev',
functions: [],
},
};
const expectedMessage = `
${chalk.yellow.underline('Service Information')}
${chalk.yellow('service:')} my-first
${chalk.yellow('stage:')} dev
${chalk.yellow('region:')} eu-west-1
${chalk.yellow('api keys:')}
None
${chalk.yellow('endpoints:')}
POST - ab12cd34ef.execute-api.us-east-1.amazonaws.com/dev
POST - ab12cd34ef.execute-api.us-east-1.amazonaws.com/dev/both
POST - ab12cd34ef.execute-api.us-east-1.amazonaws.com/dev/both/add
POST - ab12cd34ef.execute-api.us-east-1.amazonaws.com/dev/e
${chalk.yellow('functions:')}
None
`;
expect(awsInfo.display(data)).to.equal(expectedMessage);
});
it('should display only general information when stack doesn\'t exist', () => {
serverless.cli = new CLI(serverless);
sinon.stub(serverless.cli, 'consoleLog').returns();