@@ -20,23 +20,23 @@ import service from '../src/service';
2020const TEST_DEFAULT_REPO = {
2121 url : 'https://github.com/finos/git-proxy.git' ,
2222 name : 'git-proxy' ,
23- project : 'finos/git-proxy ' ,
23+ project : 'finos' ,
2424 host : 'github.com' ,
2525 proxyUrlPrefix : '/github.com/finos/git-proxy.git' ,
2626} ;
2727
2828const TEST_GITLAB_REPO = {
2929 url : 'https://gitlab.com/gitlab-community/meta.git' ,
3030 name : 'gitlab' ,
31- project : 'gitlab-community/meta ' ,
31+ project : 'gitlab-community' ,
3232 host : 'gitlab.com' ,
3333 proxyUrlPrefix : '/gitlab.com/gitlab-community/meta.git' ,
3434} ;
3535
3636const TEST_UNKNOWN_REPO = {
3737 url : 'https://github.com/finos/fdc3.git' ,
3838 name : 'fdc3' ,
39- project : 'finos/fdc3 ' ,
39+ project : 'finos' ,
4040 host : 'github.com' ,
4141 proxyUrlPrefix : '/github.com/finos/fdc3.git' ,
4242 fallbackUrlPrefix : '/finos/fdc3.git' ,
@@ -214,6 +214,31 @@ describe.skip('proxy express application', () => {
214214 expect ( res2 . status ) . toBe ( 200 ) ;
215215 expect ( res2 . text ) . toContain ( 'Rejecting repo' ) ;
216216 } , 5000 ) ;
217+
218+ it ( 'should create the default repo if it does not exist' , async function ( ) {
219+ // Remove the default repo from the db and check it no longer exists
220+ await cleanupRepo ( TEST_DEFAULT_REPO . url ) ;
221+
222+ const repo = await db . getRepoByUrl ( TEST_DEFAULT_REPO . url ) ;
223+ expect ( repo ) . toBeNull ( ) ;
224+
225+ // Restart the proxy
226+ await proxy . stop ( ) ;
227+ await proxy . start ( ) ;
228+
229+ // Check that the default repo was created in the db
230+ const repo2 = await db . getRepoByUrl ( TEST_DEFAULT_REPO . url ) ;
231+ expect ( repo2 ) . not . toBeNull ( ) ;
232+
233+ // Check that the default repo isn't duplicated on subsequent restarts
234+ await proxy . stop ( ) ;
235+ await proxy . start ( ) ;
236+
237+ const allRepos = await db . getRepos ( ) ;
238+ const matchingRepos = allRepos . filter ( ( r ) => r . url === TEST_DEFAULT_REPO . url ) ;
239+
240+ expect ( matchingRepos ) . toHaveLength ( 1 ) ;
241+ } ) ;
217242} ) ;
218243
219244describe ( 'handleRefsErrorMessage' , ( ) => {
0 commit comments