@@ -168,6 +168,31 @@ describe('ConfigLoader Tests', () => {
168
168
'Failed to load config: Failed to load parameter for matcherConfig from path /path/to/matcher/config: Failed to load matcher config' , // eslint-disable-line max-len
169
169
) ;
170
170
} ) ;
171
+
172
+ it ( 'should load config successfully from multiple paths' , async ( ) => {
173
+ process . env . PARAMETER_RUNNER_MATCHER_CONFIG_PATH = '/path/to/matcher/config-1:/path/to/matcher/config-2' ;
174
+ process . env . PARAMETER_GITHUB_APP_WEBHOOK_SECRET = '/path/to/webhook/secret' ;
175
+
176
+ const partialMatcher1 = '[{"id":"1","arn":"arn:aws:sqs:queue1","matcherConfig":{"labelMatchers":[["a"]],"exactMatch":true}}' ;
177
+ const partialMatcher2 = ',{"id":"2","arn":"arn:aws:sqs:queue2","matcherConfig":{"labelMatchers":[["b"]],"exactMatch":true}}]' ;
178
+
179
+ const combinedMatcherConfig = [
180
+ { id : '1' , arn : 'arn:aws:sqs:queue1' , matcherConfig : { labelMatchers : [ [ 'a' ] ] , exactMatch : true } } ,
181
+ { id : '2' , arn : 'arn:aws:sqs:queue2' , matcherConfig : { labelMatchers : [ [ 'b' ] ] , exactMatch : true } } ,
182
+ ] ;
183
+
184
+ vi . mocked ( getParameter ) . mockImplementation ( async ( paramPath : string ) => {
185
+ if ( paramPath === '/path/to/matcher/config-1' ) return partialMatcher1 ;
186
+ if ( paramPath === '/path/to/matcher/config-2' ) return partialMatcher2 ;
187
+ if ( paramPath === '/path/to/webhook/secret' ) return 'secret' ;
188
+ return '' ;
189
+ } ) ;
190
+
191
+ const config : ConfigWebhook = await ConfigWebhook . load ( ) ;
192
+
193
+ expect ( config . matcherConfig ) . toEqual ( combinedMatcherConfig ) ;
194
+ expect ( config . webhookSecret ) . toBe ( 'secret' ) ;
195
+ } ) ;
171
196
} ) ;
172
197
173
198
describe ( 'ConfigWebhookEventBridge' , ( ) => {
@@ -229,6 +254,30 @@ describe('ConfigLoader Tests', () => {
229
254
expect ( config . matcherConfig ) . toEqual ( matcherConfig ) ;
230
255
} ) ;
231
256
257
+ it ( 'should load config successfully from multiple paths' , async ( ) => {
258
+ process . env . REPOSITORY_ALLOW_LIST = '["repo1", "repo2"]' ;
259
+ process . env . PARAMETER_RUNNER_MATCHER_CONFIG_PATH = '/path/to/matcher/config-1:/path/to/matcher/config-2' ;
260
+
261
+ const partial1 = '[{"id":"1","arn":"arn:aws:sqs:queue1","matcherConfig":{"labelMatchers":[["x"]],"exactMatch":true}}' ;
262
+ const partial2 = ',{"id":"2","arn":"arn:aws:sqs:queue2","matcherConfig":{"labelMatchers":[["y"]],"exactMatch":true}}]' ;
263
+
264
+ const combined : RunnerMatcherConfig [ ] = [
265
+ { id : '1' , arn : 'arn:aws:sqs:queue1' , matcherConfig : { labelMatchers : [ [ 'x' ] ] , exactMatch : true } } ,
266
+ { id : '2' , arn : 'arn:aws:sqs:queue2' , matcherConfig : { labelMatchers : [ [ 'y' ] ] , exactMatch : true } } ,
267
+ ] ;
268
+
269
+ vi . mocked ( getParameter ) . mockImplementation ( async ( paramPath : string ) => {
270
+ if ( paramPath === '/path/to/matcher/config-1' ) return partial1 ;
271
+ if ( paramPath === '/path/to/matcher/config-2' ) return partial2 ;
272
+ return '' ;
273
+ } ) ;
274
+
275
+ const config : ConfigDispatcher = await ConfigDispatcher . load ( ) ;
276
+
277
+ expect ( config . repositoryAllowList ) . toEqual ( [ 'repo1' , 'repo2' ] ) ;
278
+ expect ( config . matcherConfig ) . toEqual ( combined ) ;
279
+ } ) ;
280
+
232
281
it ( 'should throw error if config loading fails' , async ( ) => {
233
282
vi . mocked ( getParameter ) . mockImplementation ( async ( paramPath : string ) => {
234
283
throw new Error ( `Parameter ${ paramPath } not found` ) ;
0 commit comments