changes default branch ref type to optionally null
Also adds a couple of tests for the default branch feature. Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
@@ -170,6 +170,68 @@ 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',
|
||||
};
|
||||
mockGetOrganizationRepositories.mockResolvedValueOnce({
|
||||
repositories: [
|
||||
{
|
||||
name: 'backstage',
|
||||
url: 'https://github.com/backstage/backstage',
|
||||
isArchived: false,
|
||||
defaultBranchRef: {
|
||||
name: 'master',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
const emitter = jest.fn();
|
||||
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
type: 'url',
|
||||
target: 'https://github.com/backstage/blob/master/catalog.yaml',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('output repositories with wildcards default branch option without catalog-info patch or branch match', async () => {
|
||||
const location: LocationSpec = {
|
||||
type: 'github-discovery',
|
||||
target: 'https://github.com/backstage',
|
||||
};
|
||||
mockGetOrganizationRepositories.mockResolvedValueOnce({
|
||||
repositories: [
|
||||
{
|
||||
name: 'backstage',
|
||||
url: 'https://github.com/backstage/backstage',
|
||||
isArchived: false,
|
||||
defaultBranchRef: {
|
||||
name: 'master',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
const emitter = jest.fn();
|
||||
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
type: 'url',
|
||||
target: 'https://github.com/backstage/blob/master/catalog-info.yaml',
|
||||
},
|
||||
optional: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('output repositories with wildcards', async () => {
|
||||
const location: LocationSpec = {
|
||||
type: 'github-discovery',
|
||||
@@ -206,7 +268,7 @@ describe('GithubDiscoveryProcessor', () => {
|
||||
name: 'techdocs-durp',
|
||||
url: 'https://github.com/backstage/techdocs-durp',
|
||||
isArchived: false,
|
||||
defaultBranchRef: undefined,
|
||||
defaultBranchRef: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -233,6 +295,7 @@ describe('GithubDiscoveryProcessor', () => {
|
||||
optional: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('filter unrelated and archived repositories', async () => {
|
||||
const location: LocationSpec = {
|
||||
type: 'github-discovery',
|
||||
|
||||
@@ -60,9 +60,9 @@ export type Repository = {
|
||||
name: string;
|
||||
url: string;
|
||||
isArchived: boolean;
|
||||
defaultBranchRef?: {
|
||||
defaultBranchRef: {
|
||||
name: string;
|
||||
};
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type Connection<T> = {
|
||||
|
||||
Reference in New Issue
Block a user