Lowercase topics

Signed-off-by: Crevil <bjoern.soerensen@gmail.com>
This commit is contained in:
Crevil
2021-06-16 16:49:45 +02:00
parent 878c1851d4
commit 3b43fc3ab8
2 changed files with 34 additions and 2 deletions
@@ -374,6 +374,39 @@ describe('publish:github', () => {
});
});
it('should lowercase topics when provided', async () => {
mockGithubClient.users.getByUsername.mockResolvedValue({
data: { type: 'User' },
});
mockGithubClient.repos.createForAuthenticatedUser.mockResolvedValue({
data: {
clone_url: 'https://github.com/clone/url.git',
html_url: 'https://github.com/html/url',
},
});
mockGithubClient.repos.replaceAllTopics.mockResolvedValue({
data: {
names: ['backstage'],
},
});
await action.handler({
...mockContext,
input: {
...mockContext.input,
topics: ['BACKSTAGE'],
},
});
expect(mockGithubClient.repos.replaceAllTopics).toHaveBeenCalledWith({
owner: 'owner',
repo: 'repo',
names: ['backstage'],
});
});
it('should call output with the remoteUrl and the repoContentsUrl', async () => {
mockGithubClient.users.getByUsername.mockResolvedValue({
data: { type: 'User' },
@@ -102,7 +102,6 @@ export function createPublishGithubAction(options: {
},
topics: {
title: 'Topics',
description: 'Uppercase letters no allowed',
type: 'array',
items: {
type: 'string',
@@ -230,7 +229,7 @@ export function createPublishGithubAction(options: {
await client.repos.replaceAllTopics({
owner,
repo,
names: topics,
names: topics.map(t => t.toLowerCase()),
});
} catch (e) {
ctx.logger.warn(`Skipping topics ${topics.join(' ')}, ${e.message}`);