@@ -241,6 +241,80 @@ describe("db config store", () => {
241241 configStore . dispose ( ) ;
242242 } ) ;
243243
244+ it ( "should add unique remote repositories to the correct list" , async ( ) => {
245+ // Initial set up
246+ const dbConfig = createDbConfig ( {
247+ remoteLists : [
248+ {
249+ name : "list1" ,
250+ repositories : [ "owner/repo1" ] ,
251+ } ,
252+ ] ,
253+ } ) ;
254+
255+ const configStore = await initializeConfig ( dbConfig , configPath , app ) ;
256+ expect (
257+ configStore . getConfig ( ) . value . databases . variantAnalysis
258+ . repositoryLists [ 0 ] ,
259+ ) . toEqual ( {
260+ name : "list1" ,
261+ repositories : [ "owner/repo1" ] ,
262+ } ) ;
263+
264+ // Add
265+ await configStore . addRemoteReposToList (
266+ [ "owner/repo1" , "owner/repo2" ] ,
267+ "list1" ,
268+ ) ;
269+
270+ // Read the config file
271+ const updatedDbConfig = ( await readJSON ( configPath ) ) as DbConfig ;
272+
273+ // Check that the config file has been updated
274+ const updatedRemoteDbs = updatedDbConfig . databases . variantAnalysis ;
275+ expect ( updatedRemoteDbs . repositories ) . toHaveLength ( 0 ) ;
276+ expect ( updatedRemoteDbs . repositoryLists ) . toHaveLength ( 1 ) ;
277+ expect ( updatedRemoteDbs . repositoryLists [ 0 ] ) . toEqual ( {
278+ name : "list1" ,
279+ repositories : [ "owner/repo1" , "owner/repo2" ] ,
280+ } ) ;
281+
282+ configStore . dispose ( ) ;
283+ } ) ;
284+
285+ it ( "should add no more than 1000 repositories to a list" , async ( ) => {
286+ // Initial set up
287+ const dbConfig = createDbConfig ( {
288+ remoteLists : [
289+ {
290+ name : "list1" ,
291+ repositories : [ ] ,
292+ } ,
293+ ] ,
294+ } ) ;
295+
296+ const configStore = await initializeConfig ( dbConfig , configPath , app ) ;
297+
298+ // Add
299+ await configStore . addRemoteReposToList (
300+ [ ...Array ( 1001 ) . keys ( ) ] . map ( ( i ) => `owner/db${ i } ` ) ,
301+ "list1" ,
302+ ) ;
303+
304+ // Read the config file
305+ const updatedDbConfig = ( await readJSON ( configPath ) ) as DbConfig ;
306+
307+ // Check that the config file has been updated
308+ const updatedRemoteDbs = updatedDbConfig . databases . variantAnalysis ;
309+ expect ( updatedRemoteDbs . repositories ) . toHaveLength ( 0 ) ;
310+ expect ( updatedRemoteDbs . repositoryLists ) . toHaveLength ( 1 ) ;
311+ expect ( updatedRemoteDbs . repositoryLists [ 0 ] . repositories ) . toHaveLength (
312+ 1000 ,
313+ ) ;
314+
315+ configStore . dispose ( ) ;
316+ } ) ;
317+
244318 it ( "should add a remote owner" , async ( ) => {
245319 // Initial set up
246320 const dbConfig = createDbConfig ( ) ;
0 commit comments