Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit 810b639

Browse files
author
subash adhikari
authored
add deploy command (#9)
1 parent fb18355 commit 810b639

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ class ServerlessSumologicPlugin {
3333
};
3434

3535
this.hooks = {
36-
'before:deploy:deploy': this.beforeDeploy.bind(this),
36+
'deploy:sumologic:deploy': this.deploy.bind(this),
37+
'before:deploy:deploy': this.deploy.bind(this),
3738
};
3839
}
3940

40-
beforeDeploy() {
41+
deploy() {
4142
return Promise.resolve()
4243
.then(() => this.validate())
4344
.then(() => this.logger.log(MESSAGE.CLI_START))

src/index.test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ describe('#SumologicPlugin', () => {
4040
endpointUrl: 'endpoint-url',
4141
});
4242

43-
expect(Object.keys(plugin.hooks)).toEqual(['before:deploy:deploy']);
43+
expect(Object.keys(plugin.hooks)).toEqual([
44+
'deploy:sumologic:deploy',
45+
'before:deploy:deploy',
46+
]);
4447
});
4548

46-
describe('#beforeDeploy', () => {
49+
describe('#deploy', () => {
4750
let plugin;
4851

4952
beforeEach(() => {
@@ -57,12 +60,12 @@ describe('#SumologicPlugin', () => {
5760

5861
it('should validate plugin configuration', async () => {
5962
const spy = jest.spyOn(plugin, 'validate');
60-
await plugin.beforeDeploy();
63+
await plugin.deploy();
6164
expect(spy).toHaveBeenCalled();
6265
});
6366

6467
it('should generate template', async () => {
65-
await plugin.beforeDeploy();
68+
await plugin.deploy();
6669
expect(mockGenerateTemplate).toHaveBeenCalledWith({
6770
config: {
6871
endpointUrl: 'endpoint-url',
@@ -77,7 +80,7 @@ describe('#SumologicPlugin', () => {
7780
it('should deploy sumologic stack', async () => {
7881
mockGenerateTemplate.mockReturnValue('template');
7982
const spy = jest.spyOn(plugin.cloudformation, 'deploy');
80-
await plugin.beforeDeploy();
83+
await plugin.deploy();
8184
expect(spy).toHaveBeenCalledWith({
8285
config: {
8386
endpointUrl: 'endpoint-url',
@@ -94,7 +97,7 @@ describe('#SumologicPlugin', () => {
9497
const spy = jest.spyOn(plugin, 'validate');
9598
spy.mockRejectedValue(new Error('cannot generate template'));
9699
return plugin
97-
.beforeDeploy()
100+
.deploy()
98101
.then(() => expect(false).toBeTruthy())
99102
.catch(err => expect(err).toEqual('cannot generate template'));
100103
});

0 commit comments

Comments
 (0)