Skip to content

Commit f416bd1

Browse files
committed
test(bulk-import): add test case for fetching all repositories with non-root catalog location
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
1 parent bc09b89 commit f416bd1

2 files changed

Lines changed: 133 additions & 0 deletions

File tree

workspaces/bulk-import/plugins/bulk-import-backend/src/service/handlers/repository/repositories-gitlab.test.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,73 @@ describe('repositories', () => {
297297
totalCount: 0,
298298
});
299299
});
300+
301+
it('returns all repos even though a non-root catalog location exists', async () => {
302+
const { server, mockCatalogClient } = useTestData();
303+
304+
server.use(
305+
rest.get(CATALOG_API_LOCATIONS_LOCAL_ADDR, (_, res, ctx) =>
306+
res(
307+
ctx.status(200),
308+
ctx.json([
309+
{
310+
data: {
311+
id: 'imported-funtimes-nested',
312+
target:
313+
'http://localhost:8765/saltypig1/funtimes/blob/main/packages/backend/catalog-info.yaml',
314+
type: 'url',
315+
},
316+
},
317+
]),
318+
),
319+
),
320+
);
321+
322+
const backendServer = await startBackendServer(
323+
mockCatalogClient,
324+
AuthorizeResult.ALLOW,
325+
);
326+
327+
const response = await request(backendServer)
328+
.get('/api/bulk-import/repositories')
329+
.query({ approvalTool: 'GITLAB' });
330+
331+
expect(response.status).toEqual(200);
332+
expect(response.body).toEqual({
333+
approvalTool: 'GITLAB',
334+
errors: [],
335+
repositories: [
336+
{
337+
defaultBranch: 'main',
338+
errors: [],
339+
id: 'saltypig1/dolbear',
340+
lastUpdate: '2025-07-31T14:52:27.849Z',
341+
name: 'dolbear',
342+
organization: 'saltypig1',
343+
url: 'http://localhost:8765/saltypig1/dolbear',
344+
},
345+
{
346+
defaultBranch: 'main',
347+
errors: [],
348+
id: 'saltypig1/funtimes',
349+
lastUpdate: '2025-08-15T15:03:44.927Z',
350+
name: 'funtimes',
351+
organization: 'saltypig1',
352+
url: 'http://localhost:8765/saltypig1/funtimes',
353+
},
354+
{
355+
defaultBranch: 'main',
356+
errors: [],
357+
id: 'saltypig1/swapi-node',
358+
lastUpdate: '2025-07-31T14:54:57.289Z',
359+
name: 'swapi-node',
360+
organization: 'saltypig1',
361+
url: 'http://localhost:8765/saltypig1/swapi-node',
362+
},
363+
],
364+
totalCount: 3,
365+
});
366+
});
300367
});
301368
});
302369

workspaces/bulk-import/plugins/bulk-import-backend/src/service/handlers/repository/repositories.test.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,72 @@ describe('repositories', () => {
334334
totalCount: 0,
335335
});
336336
});
337+
338+
it('returns all repos even though a non-root catalog location exists', async () => {
339+
const { server, mockCatalogClient } = useTestData();
340+
341+
server.use(
342+
rest.get(CATALOG_API_LOCATIONS_LOCAL_ADDR, (_, res, ctx) =>
343+
res(
344+
ctx.status(200),
345+
ctx.json([
346+
{
347+
data: {
348+
id: 'imported-animated-happiness-sub',
349+
target:
350+
'http://localhost:8765/octocat/animated-happiness/blob/master/monorepo/nested/path/catalog-info.yaml',
351+
type: 'url',
352+
},
353+
},
354+
]),
355+
),
356+
),
357+
);
358+
359+
const backendServer = await startBackendServer(
360+
mockCatalogClient,
361+
AuthorizeResult.ALLOW,
362+
);
363+
364+
const response = await request(backendServer).get(
365+
'/api/bulk-import/repositories',
366+
);
367+
368+
expect(response.status).toEqual(200);
369+
expect(response.body).toEqual({
370+
errors: [],
371+
repositories: [
372+
{
373+
defaultBranch: 'master',
374+
errors: [],
375+
id: 'octocat/animated-happiness',
376+
lastUpdate: '2011-01-26T19:14:43Z',
377+
name: 'animated-happiness',
378+
organization: 'octocat',
379+
url: 'http://localhost:8765/octocat/animated-happiness',
380+
},
381+
{
382+
defaultBranch: 'master',
383+
errors: [],
384+
id: 'octocat/Hello-World',
385+
lastUpdate: '2011-01-26T19:14:43Z',
386+
name: 'Hello-World',
387+
organization: 'octocat',
388+
url: 'http://localhost:8765/octocat/Hello-World',
389+
},
390+
{
391+
defaultBranch: 'master',
392+
errors: [],
393+
id: 'my-user/Lorem-Ipsum',
394+
lastUpdate: '2011-01-26T19:14:43Z',
395+
name: 'Lorem-Ipsum',
396+
organization: 'my-user',
397+
url: 'http://localhost:8765/my-user/Lorem-Ipsum',
398+
},
399+
],
400+
totalCount: 3,
401+
});
402+
});
337403
});
338404
});
339405

0 commit comments

Comments
 (0)