fix: unit tests

Signed-off-by: John Redwood <john.r.k.redwood@gmail.com>
This commit is contained in:
John Redwood
2025-10-19 21:48:41 +11:00
parent ff96d7e59b
commit 75e3f32ccd
@@ -79,6 +79,37 @@ describe('gitlab:create-deploy-token', () => {
name: 'tokenname',
username: 'tokenuser',
scopes: ['read_repository'],
token: 'oidctoken',
},
});
expect(mockGitlabClient.DeployTokens.create).toHaveBeenCalledWith(
'tokenname',
['read_repository'],
{
projectId: '123',
username: 'tokenuser',
},
);
expect(mockContext.output).toHaveBeenCalledWith('deploy_token', 'TOKEN');
expect(mockContext.output).toHaveBeenCalledWith('user', 'User');
});
it('should work when there is not a token provided through ctx.input e.g. integration token', async () => {
mockGitlabClient.DeployTokens.create.mockResolvedValue({
token: 'TOKEN',
username: 'User',
});
await action.handler({
...mockContext,
input: {
repoUrl: 'gitlab.com?repo=bob&owner=owner',
projectId: '123',
name: 'tokenname',
username: 'tokenuser',
scopes: ['read_repository'],
},
});