Fixing broken test and adding one for the undefined case

Signed-off-by: Nicolas Arnold <nic@roadie.io>
This commit is contained in:
Nicolas Arnold
2021-08-27 09:59:29 +02:00
parent 0785cf54c3
commit 391490d75e
@@ -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',