@@ -16,11 +16,11 @@ describe('DisplayServiceInfo', () => {
16
16
serverless = new Serverless ( ) ;
17
17
serverless . service . service = 'my-service' ;
18
18
serverless . service . functions = {
19
- func1 : {
19
+ ' func1' : {
20
20
handler : 'handler' ,
21
21
events : [ { http : 'foo' } ] ,
22
22
} ,
23
- func2 : {
23
+ ' func2' : {
24
24
handler : 'handler' ,
25
25
events : [
26
26
{
@@ -32,6 +32,11 @@ describe('DisplayServiceInfo', () => {
32
32
} ,
33
33
] ,
34
34
} ,
35
+ 'my-func3' : {
36
+ name : 'my-func3' ,
37
+ handler : 'handler' ,
38
+ events : [ { http : 'foo' } ] ,
39
+ } ,
35
40
} ;
36
41
serverless . service . provider = {
37
42
project : 'my-project' ,
@@ -131,6 +136,37 @@ describe('DisplayServiceInfo', () => {
131
136
} ) ;
132
137
} ) ;
133
138
139
+ it ( 'should gather the resource data when the function name is specified' , ( ) => {
140
+ const resources = {
141
+ resources : [
142
+ { type : 'resource.which.should.be.filterered' , name : 'someResource' } ,
143
+ {
144
+ type : 'gcp-types/cloudfunctions-v1:projects.locations.functions' ,
145
+ name : 'my-func3' ,
146
+ } ,
147
+ ] ,
148
+ } ;
149
+
150
+ const expectedData = {
151
+ service : 'my-service' ,
152
+ project : 'my-project' ,
153
+ stage : 'dev' ,
154
+ region : 'us-central1' ,
155
+ resources : {
156
+ functions : [
157
+ {
158
+ name : 'my-func3' ,
159
+ resource : 'https://us-central1-my-project.cloudfunctions.net/my-func3' ,
160
+ } ,
161
+ ] ,
162
+ } ,
163
+ } ;
164
+
165
+ return googleInfo . gatherData ( resources ) . then ( ( data ) => {
166
+ expect ( data ) . toEqual ( expectedData ) ;
167
+ } ) ;
168
+ } ) ;
169
+
134
170
it ( 'should resolve with empty data if resource type is not matching' , ( ) => {
135
171
const resources = {
136
172
resources : [ { type : 'resource.which.should.be.filterered' , name : 'someResource' } ] ,
0 commit comments