diff --git a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts index d5173657b7..12d9e66659 100644 --- a/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts +++ b/plugins/catalog-backend/src/ingestion/processors/GithubDiscoveryProcessor.test.ts @@ -173,16 +173,16 @@ describe('GithubDiscoveryProcessor', () => { it('output repositories with wildcards default branch option', async () => { const location: LocationSpec = { type: 'github-discovery', - target: 'https://github.com/backstage/techdocs-*/blob/-/catalog.yaml', + target: 'https://github.com/backstage/*/blob/-/catalog.yaml', }; mockGetOrganizationRepositories.mockResolvedValueOnce({ repositories: [ { name: 'backstage', - url: 'https://github.com/backstage/backstage', + url: 'https://github.com/backstage/tech-docs', isArchived: false, defaultBranchRef: { - name: 'master', + name: 'main', }, }, ], @@ -195,12 +195,35 @@ describe('GithubDiscoveryProcessor', () => { type: 'location', location: { type: 'url', - target: 'https://github.com/backstage/blob/master/catalog.yaml', + target: + 'https://github.com/backstage/tech-docs/blob/main/catalog.yaml', }, optional: true, }); }); + it("doesn't output repositories as default branch returned is empty", async () => { + const location: LocationSpec = { + type: 'github-discovery', + target: 'https://github.com/backstage/blob/-/catalog.yaml', + }; + mockGetOrganizationRepositories.mockResolvedValueOnce({ + repositories: [ + { + name: 'backstage', + url: 'https://github.com/backstage/tech-docs', + isArchived: false, + defaultBranchRef: null, + }, + ], + }); + const emitter = jest.fn(); + + await processor.readLocation(location, false, emitter); + + expect(emitter).not.toHaveBeenCalled(); + }); + it('output repositories with wildcards default branch option without catalog-info patch or branch match', async () => { const location: LocationSpec = { type: 'github-discovery',