renamed utility to entityRefToName based on code review
Signed-off-by: Phred <fearphage@gmail.com>
This commit is contained in:
+2
-2
@@ -28,7 +28,7 @@ import {
|
||||
import { when } from 'jest-when';
|
||||
import { PassThrough } from 'stream';
|
||||
import { createGithubRepoCreateAction } from './githubRepoCreate';
|
||||
import { familiarizeEntityName } from '../helpers';
|
||||
import { entityRefToName } from '../helpers';
|
||||
|
||||
const mockOctokit = {
|
||||
rest: {
|
||||
@@ -90,7 +90,7 @@ describe('github:repo:create', () => {
|
||||
integrations,
|
||||
githubCredentialsProvider,
|
||||
});
|
||||
(familiarizeEntityName as jest.Mock).mockImplementation((s: string) => s);
|
||||
(entityRefToName as jest.Mock).mockImplementation((s: string) => s);
|
||||
});
|
||||
|
||||
afterEach(jest.resetAllMocks);
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
initRepoAndPush,
|
||||
} from '../helpers';
|
||||
import { getRepoSourceDirectory, parseRepoUrl } from '../publish/util';
|
||||
import { familiarizeEntityName } from '../../builtin/helpers';
|
||||
import { entityRefToName } from '../../builtin/helpers';
|
||||
|
||||
const DEFAULT_TIMEOUT_MS = 60_000;
|
||||
|
||||
@@ -219,13 +219,13 @@ export async function createGithubRepoWithCollaboratorsAndTopics(
|
||||
await client.rest.repos.addCollaborator({
|
||||
owner,
|
||||
repo,
|
||||
username: familiarizeEntityName(collaborator.user),
|
||||
username: entityRefToName(collaborator.user),
|
||||
permission: collaborator.access,
|
||||
});
|
||||
} else if ('team' in collaborator) {
|
||||
await client.rest.teams.addOrUpdateRepoPermissionsInOrg({
|
||||
org: owner,
|
||||
team_slug: familiarizeEntityName(collaborator.team),
|
||||
team_slug: entityRefToName(collaborator.team),
|
||||
owner,
|
||||
repo,
|
||||
permission: collaborator.access,
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
*/
|
||||
|
||||
import { Git, getVoidLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
commitAndPushRepo,
|
||||
familiarizeEntityName,
|
||||
initRepoAndPush,
|
||||
} from './helpers';
|
||||
import { commitAndPushRepo, entityRefToName, initRepoAndPush } from './helpers';
|
||||
|
||||
jest.mock('@backstage/backend-common', () => ({
|
||||
Git: {
|
||||
@@ -306,7 +302,7 @@ describe('commitAndPushRepo', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('familiarizeEntityName', () => {
|
||||
describe('entityRefToName', () => {
|
||||
it.each([
|
||||
'user:default/catpants',
|
||||
'group:default/catpants',
|
||||
@@ -316,6 +312,6 @@ describe('familiarizeEntityName', () => {
|
||||
'group:custom/catpants',
|
||||
'catpants',
|
||||
])('should parse: "%s"', (entityName: string) => {
|
||||
expect(familiarizeEntityName(entityName)).toEqual('catpants');
|
||||
expect(entityRefToName(entityName)).toEqual('catpants');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -297,6 +297,6 @@ export function getGitCommitMessage(
|
||||
: config.getOptionalString('scaffolder.defaultCommitMessage');
|
||||
}
|
||||
|
||||
export function familiarizeEntityName(name: string): string {
|
||||
export function entityRefToName(name: string): string {
|
||||
return name.replace(/^.*[:/]/g, '');
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import { when } from 'jest-when';
|
||||
import { PassThrough } from 'stream';
|
||||
import {
|
||||
enableBranchProtectionOnDefaultRepoBranch,
|
||||
familiarizeEntityName,
|
||||
entityRefToName,
|
||||
initRepoAndPush,
|
||||
} from '../helpers';
|
||||
import { createPublishGithubAction } from './github';
|
||||
@@ -69,7 +69,7 @@ describe('publish:github', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const { familiarizeEntityName: realFamiliarizeEntityName } =
|
||||
const { entityRefToName: realFamiliarizeEntityName } =
|
||||
jest.requireActual('../helpers');
|
||||
const integrations = ScmIntegrations.fromConfig(config);
|
||||
let githubCredentialsProvider: GithubCredentialsProvider;
|
||||
@@ -99,7 +99,7 @@ describe('publish:github', () => {
|
||||
});
|
||||
|
||||
// restore real implmentation
|
||||
(familiarizeEntityName as jest.Mock).mockImplementation(
|
||||
(entityRefToName as jest.Mock).mockImplementation(
|
||||
realFamiliarizeEntityName,
|
||||
);
|
||||
});
|
||||
@@ -709,8 +709,8 @@ describe('publish:github', () => {
|
||||
permission: 'push',
|
||||
});
|
||||
|
||||
expect(familiarizeEntityName).toHaveBeenCalledWith('user:robot-1');
|
||||
expect(familiarizeEntityName).toHaveBeenCalledWith('group:default/robot-2');
|
||||
expect(entityRefToName).toHaveBeenCalledWith('user:robot-1');
|
||||
expect(entityRefToName).toHaveBeenCalledWith('group:default/robot-2');
|
||||
});
|
||||
|
||||
it('should ignore failures when adding multiple collaborators', async () => {
|
||||
|
||||
Reference in New Issue
Block a user