@@ -18,104 +18,99 @@ const correctConfigWithStageFilter = {
18
18
filterPattern : 'Test Pattern' ,
19
19
stages : [ 'production' ] ,
20
20
} ;
21
+
22
+ const Serverless = require ( 'serverless' ) ;
23
+ const AwsProvider = require ( 'serverless/lib/plugins/aws/provider/awsProvider' ) ;
24
+
25
+ const createServerless = ( options , service ) => {
26
+ const serverless = new Serverless ( options ) ;
27
+ serverless . cli = {
28
+ log ( ) {
29
+ } ,
30
+ } ;
31
+ new AwsProvider ( serverless , options ) ; // eslint-disable-line no-new
32
+ serverless . service . update ( service ) ;
33
+ serverless . service . setFunctionNames ( options ) ;
34
+ return serverless ;
35
+ } ;
36
+
21
37
const constructPluginResources = ( logForwarding ) => {
22
- const serverless = {
23
- service : {
24
- provider : {
25
- region : 'us-moon-1' ,
26
- stage : 'test-stage' ,
27
- } ,
28
- custom : {
29
- logForwarding,
30
- } ,
31
- resources : {
32
- Resources : {
33
- TestExistingFilter : {
34
- Type : 'AWS:Test:Filter' ,
35
- } ,
36
- } ,
37
- } ,
38
- functions : {
39
- testFunctionOne : {
40
- name : 'functionOne' ,
41
- filterPattern : 'Pattern' ,
42
- } ,
43
- testFunctionTwo : {
44
- name : 'functionTwo' ,
38
+ const options = { } ;
39
+ const serverless = createServerless ( options , {
40
+ provider : {
41
+ region : 'us-moon-1' ,
42
+ stage : 'test-stage' ,
43
+ } ,
44
+ custom : {
45
+ logForwarding,
46
+ } ,
47
+ resources : {
48
+ Resources : {
49
+ TestExistingFilter : {
50
+ Type : 'AWS:Test:Filter' ,
45
51
} ,
46
52
} ,
47
- service : 'test-service' ,
48
53
} ,
49
- cli : {
50
- log ( ) {
54
+ functions : {
55
+ testFunctionOne : {
56
+ filterPattern : 'Pattern' ,
57
+ } ,
58
+ testFunctionTwo : {
51
59
} ,
52
60
} ,
53
- } ;
54
- return new LogForwardingPlugin ( serverless , { } ) ;
61
+ service : 'test-service' ,
62
+ } ) ;
63
+ return new LogForwardingPlugin ( serverless , options ) ;
55
64
} ;
56
65
const constructPluginNoResources = ( logForwarding ) => {
57
- const serverless = {
58
- service : {
59
- provider : {
60
- region : 'us-moon-1' ,
61
- stage : 'test-stage' ,
62
- } ,
63
- custom : {
64
- logForwarding,
65
- } ,
66
- resources : undefined ,
67
- functions : {
68
- testFunctionOne : {
69
- name : 'functionOne' ,
70
- } ,
71
- testFunctionTwo : {
72
- name : 'functionTwo' ,
73
- } ,
74
- } ,
75
- service : 'test-service' ,
66
+ const options = { } ;
67
+ const serverless = createServerless ( options , {
68
+ provider : {
69
+ region : 'us-moon-1' ,
70
+ stage : 'test-stage' ,
76
71
} ,
77
- cli : {
78
- log ( ) {
72
+ custom : {
73
+ logForwarding,
74
+ } ,
75
+ functions : {
76
+ testFunctionOne : {
77
+ } ,
78
+ testFunctionTwo : {
79
79
} ,
80
80
} ,
81
- } ;
82
- return new LogForwardingPlugin ( serverless , { } ) ;
81
+ service : 'test-service' ,
82
+ } ) ;
83
+ serverless . service . resources = undefined ;
84
+ return new LogForwardingPlugin ( serverless , options ) ;
83
85
} ;
84
86
85
87
const constructPluginResourcesWithParam = ( logForwarding ) => {
86
- const serverless = {
87
- service : {
88
- provider : {
89
- region : 'us-moon-1' ,
90
- stage : 'test-stage' ,
91
- } ,
92
- custom : {
93
- logForwarding,
94
- } ,
95
- resources : {
96
- Resources : {
97
- TestExistingFilter : {
98
- Type : 'AWS:Test:Filter' ,
99
- } ,
100
- } ,
101
- } ,
102
- functions : {
103
- testFunctionOne : {
104
- name : 'functionOne' ,
105
- filterPattern : 'Pattern' ,
106
- } ,
107
- testFunctionTwo : {
108
- name : 'functionTwo' ,
88
+ const options = { stage : 'dev' } ;
89
+ const serverless = createServerless ( options , {
90
+ provider : {
91
+ region : 'us-moon-1' ,
92
+ stage : 'test-stage' ,
93
+ } ,
94
+ custom : {
95
+ logForwarding,
96
+ } ,
97
+ resources : {
98
+ Resources : {
99
+ TestExistingFilter : {
100
+ Type : 'AWS:Test:Filter' ,
109
101
} ,
110
102
} ,
111
- service : 'test-service' ,
112
103
} ,
113
- cli : {
114
- log ( ) {
104
+ functions : {
105
+ testFunctionOne : {
106
+ filterPattern : 'Pattern' ,
107
+ } ,
108
+ testFunctionTwo : {
115
109
} ,
116
110
} ,
117
- } ;
118
- return new LogForwardingPlugin ( serverless , { stage : 'dev' } ) ;
111
+ service : 'test-service' ,
112
+ } ) ;
113
+ return new LogForwardingPlugin ( serverless , options ) ;
119
114
} ;
120
115
121
116
describe ( 'Given a serverless config' , ( ) => {
@@ -143,6 +138,7 @@ describe('Given a serverless config', () => {
143
138
} ,
144
139
DependsOn : [
145
140
'LogForwardingLambdaPermission' ,
141
+ 'TestFunctionOneLogGroup' ,
146
142
] ,
147
143
} ,
148
144
SubscriptionFiltertestFunctionTwo : {
@@ -154,6 +150,7 @@ describe('Given a serverless config', () => {
154
150
} ,
155
151
DependsOn : [
156
152
'LogForwardingLambdaPermission' ,
153
+ 'TestFunctionTwoLogGroup' ,
157
154
] ,
158
155
} ,
159
156
} ,
@@ -185,6 +182,7 @@ describe('Given a serverless config', () => {
185
182
} ,
186
183
DependsOn : [
187
184
'LogForwardingLambdaPermission' ,
185
+ 'TestFunctionOneLogGroup' ,
188
186
] ,
189
187
} ,
190
188
SubscriptionFiltertestFunctionTwo : {
@@ -196,6 +194,7 @@ describe('Given a serverless config', () => {
196
194
} ,
197
195
DependsOn : [
198
196
'LogForwardingLambdaPermission' ,
197
+ 'TestFunctionTwoLogGroup' ,
199
198
] ,
200
199
} ,
201
200
} ,
@@ -224,6 +223,7 @@ describe('Given a serverless config', () => {
224
223
} ,
225
224
DependsOn : [
226
225
'LogForwardingLambdaPermission' ,
226
+ 'TestFunctionOneLogGroup' ,
227
227
] ,
228
228
} ,
229
229
SubscriptionFiltertestFunctionTwo : {
@@ -235,6 +235,7 @@ describe('Given a serverless config', () => {
235
235
} ,
236
236
DependsOn : [
237
237
'LogForwardingLambdaPermission' ,
238
+ 'TestFunctionTwoLogGroup' ,
238
239
] ,
239
240
} ,
240
241
} ,
@@ -266,6 +267,7 @@ describe('Given a serverless config', () => {
266
267
} ,
267
268
DependsOn : [
268
269
'LogForwardingLambdaPermission' ,
270
+ 'TestFunctionOneLogGroup' ,
269
271
] ,
270
272
} ,
271
273
SubscriptionFiltertestFunctionTwo : {
@@ -277,6 +279,7 @@ describe('Given a serverless config', () => {
277
279
} ,
278
280
DependsOn : [
279
281
'LogForwardingLambdaPermission' ,
282
+ 'TestFunctionTwoLogGroup' ,
280
283
] ,
281
284
} ,
282
285
} ,
0 commit comments