adds tests and handling if edit url is unset

Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
Brian Fletcher
2022-05-25 10:45:07 +01:00
parent 8335a6f6f3
commit be4aff4ac9
2 changed files with 16 additions and 5 deletions
@@ -86,6 +86,7 @@ describe('github', () => {
name: 'Team',
description: 'The one and only team',
avatarUrl: 'http://example.com/team.jpeg',
editTeamUrl: 'http://example.com/orgs/blah/teams/team/edit',
parentTeam: {
slug: 'parent',
combinedSlug: '',
@@ -109,6 +110,11 @@ describe('github', () => {
metadata: expect.objectContaining({
name: 'team',
description: 'The one and only team',
annotations: {
'github.com/team-slug': 'blah/team',
'backstage.io/edit-url':
'http://example.com/orgs/blah/teams/team/edit',
},
}),
spec: {
type: 'team',
@@ -52,7 +52,7 @@ export type Team = {
name?: string;
description?: string;
avatarUrl?: string;
editTeamUrl: string;
editTeamUrl?: string;
parentTeam?: Team;
members: Connection<User>;
};
@@ -181,15 +181,20 @@ export async function getOrganizationTeams(
const groupMemberUsers = new Map<string, string[]>();
const mapper = async (team: Team) => {
const annotations: { [annotationName: string]: string } = {
'github.com/team-slug': team.combinedSlug,
};
if (team.editTeamUrl) {
annotations['backstage.io/edit-url'] = team.editTeamUrl;
}
const entity: GroupEntity = {
apiVersion: 'backstage.io/v1alpha1',
kind: 'Group',
metadata: {
name: team.slug,
annotations: {
'github.com/team-slug': team.combinedSlug,
'backstage.io/edit-url': team.editTeamUrl,
},
annotations,
},
spec: {
type: 'team',