@@ -26,6 +26,7 @@ describe("ProjectsService", async () => {
2626 let member : User ;
2727 let stranger : User ;
2828 let org : Organization ;
29+ let anotherOrg : Organization ;
2930
3031 beforeEach ( async ( ) => {
3132 container = createTestContainer ( ) ;
@@ -40,12 +41,16 @@ describe("ProjectsService", async () => {
4041 // create the org
4142 const orgService = container . get ( OrganizationService ) ;
4243 org = await orgService . createOrganization ( owner . id , "my-org" ) ;
44+ anotherOrg = await orgService . createOrganization ( owner . id , "another-org" ) ;
4345
4446 // create and add a member
4547 member = await userDB . newUser ( ) ;
4648 const invite = await orgService . getOrCreateInvite ( owner . id , org . id ) ;
4749 await orgService . joinOrganization ( member . id , invite . id ) ;
4850
51+ const anotherInvite = await orgService . getOrCreateInvite ( owner . id , anotherOrg . id ) ;
52+ await orgService . joinOrganization ( member . id , anotherInvite . id ) ;
53+
4954 // create a stranger
5055 stranger = await userDB . newUser ( ) ;
5156 } ) ;
@@ -296,6 +301,30 @@ describe("ProjectsService", async () => {
296301 } ) ;
297302 } ) ;
298303
304+ it ( "should find projects by clone url" , async ( ) => {
305+ const ps = container . get ( ProjectsService ) ;
306+ const cloneUrl = "https://github.com/gitpod-io/gitpod.git" ;
307+
308+ await createTestProject ( ps , org , owner , { name : "my-project" , cloneUrl } ) ;
309+ await createTestProject ( ps , org , owner , { name : "my-project-2" , cloneUrl } ) ;
310+
311+ // Create data which should not be found
312+ await createTestProject ( ps , org , owner , {
313+ name : "my-project-3" ,
314+ cloneUrl : "https://github.com/gitpod-io/different-repo" ,
315+ } ) ;
316+ await createTestProject ( ps , anotherOrg , owner , {
317+ name : "my-project-4" ,
318+ cloneUrl,
319+ } ) ;
320+
321+ const foundProjects = await ps . findProjectsByCloneUrl ( owner . id , cloneUrl , org . id ) ;
322+ expect ( foundProjects . length ) . to . equal ( 2 ) ;
323+
324+ const foundProjectsForAnyOrg = await ps . findProjectsByCloneUrl ( owner . id , cloneUrl ) ;
325+ expect ( foundProjectsForAnyOrg . length ) . to . equal ( 3 ) ;
326+ } ) ;
327+
299328 async function createTestProject (
300329 ps : ProjectsService ,
301330 org : Organization ,
0 commit comments