@@ -26,6 +26,7 @@ describe("ProjectsService", async () => {
26
26
let member : User ;
27
27
let stranger : User ;
28
28
let org : Organization ;
29
+ let anotherOrg : Organization ;
29
30
30
31
beforeEach ( async ( ) => {
31
32
container = createTestContainer ( ) ;
@@ -40,12 +41,16 @@ describe("ProjectsService", async () => {
40
41
// create the org
41
42
const orgService = container . get ( OrganizationService ) ;
42
43
org = await orgService . createOrganization ( owner . id , "my-org" ) ;
44
+ anotherOrg = await orgService . createOrganization ( owner . id , "another-org" ) ;
43
45
44
46
// create and add a member
45
47
member = await userDB . newUser ( ) ;
46
48
const invite = await orgService . getOrCreateInvite ( owner . id , org . id ) ;
47
49
await orgService . joinOrganization ( member . id , invite . id ) ;
48
50
51
+ const anotherInvite = await orgService . getOrCreateInvite ( owner . id , anotherOrg . id ) ;
52
+ await orgService . joinOrganization ( member . id , anotherInvite . id ) ;
53
+
49
54
// create a stranger
50
55
stranger = await userDB . newUser ( ) ;
51
56
} ) ;
@@ -296,6 +301,30 @@ describe("ProjectsService", async () => {
296
301
} ) ;
297
302
} ) ;
298
303
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
+
299
328
async function createTestProject (
300
329
ps : ProjectsService ,
301
330
org : Organization ,
0 commit comments