From a2354a23b55e447e2653b9dae1fa129be81e062f Mon Sep 17 00:00:00 2001 From: Benjamin Janssens Date: Thu, 14 Aug 2025 17:28:03 +0200 Subject: [PATCH] test(catalog): add tests for GithubEntityProviderConfig Signed-off-by: Benjamin Janssens --- .../GithubEntityProviderConfig.test.ts | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-backend-module-github/src/providers/GithubEntityProviderConfig.test.ts b/plugins/catalog-backend-module-github/src/providers/GithubEntityProviderConfig.test.ts index 28a3f5e7dd..3b1743e404 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubEntityProviderConfig.test.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubEntityProviderConfig.test.ts @@ -111,13 +111,20 @@ describe('readProviderConfigs', () => { }, }, }, + providerAppOnly: { + app: '1234', + }, + providerAppAndOrganization: { + app: '1234', + organization: 'test-org1', + }, }, }, }, }); const providerConfigs = readProviderConfigs(config); - expect(providerConfigs).toHaveLength(10); + expect(providerConfigs).toHaveLength(12); expect(providerConfigs[0]).toEqual({ id: 'providerOrganizationOnly', organization: 'test-org1', @@ -313,6 +320,45 @@ describe('readProviderConfigs', () => { }, validateLocationsExist: false, }); + expect(providerConfigs[10]).toEqual({ + id: 'providerAppOnly', + app: 1234, + catalogPath: '/catalog-info.yaml', + host: 'github.com', + filters: { + repository: undefined, + branch: undefined, + allowForks: true, + topic: { + include: undefined, + exclude: undefined, + }, + visibility: undefined, + allowArchived: false, + }, + schedule: DEFAULT_GITHUB_ENTITY_PROVIDER_CONFIG_SCHEDULE, + validateLocationsExist: false, + }); + expect(providerConfigs[11]).toEqual({ + id: 'providerAppAndOrganization', + app: 1234, + organization: 'test-org1', + catalogPath: '/catalog-info.yaml', + host: 'github.com', + filters: { + repository: undefined, + branch: undefined, + allowForks: true, + topic: { + include: undefined, + exclude: undefined, + }, + visibility: undefined, + allowArchived: false, + }, + schedule: DEFAULT_GITHUB_ENTITY_PROVIDER_CONFIG_SCHEDULE, + validateLocationsExist: false, + }); }); it('defaults validateLocationsExist to false', () => { @@ -365,4 +411,18 @@ describe('readProviderConfigs', () => { expect(() => readProviderConfigs(config)).toThrow(); }); + + it('throws an error when no organization or app is configured', () => { + const config = new ConfigReader({ + catalog: { + providers: { + github: { + catalogPath: '/*/catalog-info.yaml', + }, + }, + }, + }); + + expect(() => readProviderConfigs(config)).toThrow(); + }); });