From 919b52f7dfdb3a28d159d73f927c1cd325f5e017 Mon Sep 17 00:00:00 2001 From: alessandro Date: Mon, 7 Aug 2023 10:02:22 +0200 Subject: [PATCH] feat(catalog-backend-module-gitlab): Fix tests for archived projects Signed-off-by: alessandro --- .../src/GitLabDiscoveryProcessor.test.ts | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.test.ts b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.test.ts index 8a8ceccaf0..a56c229105 100644 --- a/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.test.ts +++ b/plugins/catalog-backend-module-gitlab/src/GitLabDiscoveryProcessor.test.ts @@ -86,11 +86,13 @@ function setupFakeServer( const last_activity_after = req.url.searchParams.get( 'last_activity_after', ); - const filteredData = response.data.filter( - v => - !last_activity_after || - Date.parse(v.last_activity_at) >= Date.parse(last_activity_after), - ); + const filteredData = response.data + .filter( + v => + !last_activity_after || + Date.parse(v.last_activity_at) >= Date.parse(last_activity_after), + ) + .filter(v => archived || !v.archived); return res( ctx.set('x-next-page', response.nextPage?.toString() ?? ''), @@ -225,37 +227,6 @@ describe('GitlabDiscoveryProcessor', () => { nextPage: 2, }; case 2: - if (request.archived) { - return { - data: [ - { - id: 3, - archived: false, - default_branch: 'master', - last_activity_at: '2021-08-05T11:03:05.774Z', - web_url: 'https://gitlab.fake/3', - path_with_namespace: '3', - }, - { - id: 4, - archived: true, // ARCHIVED - default_branch: 'master', - last_activity_at: '2021-08-05T11:03:05.774Z', - web_url: 'https://gitlab.fake/4', - path_with_namespace: '4', - }, - { - id: 5, - archived: false, - default_branch: undefined, // MISSING DEFAULT BRANCH - last_activity_at: '2021-08-05T11:03:05.774Z', - web_url: 'https://gitlab.fake/g/5', - path_with_namespace: 'g/5', - }, - ], - }; - } - return { data: [ { @@ -266,6 +237,14 @@ describe('GitlabDiscoveryProcessor', () => { web_url: 'https://gitlab.fake/3', path_with_namespace: '3', }, + { + id: 4, + archived: true, // ARCHIVED + default_branch: 'master', + last_activity_at: '2021-08-05T11:03:05.774Z', + web_url: 'https://gitlab.fake/4', + path_with_namespace: '4', + }, { id: 5, archived: false,