feat: 补齐 Gitea ref 提交摘要
This commit is contained in:
@@ -20,6 +20,7 @@ describe('ProjectsService', () => {
|
||||
giteaConfigured?: boolean;
|
||||
branches?: Array<{ name: string; commitSha: string }>;
|
||||
tags?: Array<{ name: string; commitSha: string }>;
|
||||
commits?: Record<string, { sha: string; message: string }>;
|
||||
}) {
|
||||
const repository = {
|
||||
findMany: jest.fn(() => Promise.resolve([project])),
|
||||
@@ -37,7 +38,18 @@ describe('ProjectsService', () => {
|
||||
listTags: jest.fn(() =>
|
||||
Promise.resolve(options?.tags ?? [{ name: 'v1.0.0', commitSha: 'def' }]),
|
||||
),
|
||||
} satisfies Pick<GiteaClient, 'healthSummary' | 'listBranches' | 'listTags'>;
|
||||
getCommit: jest.fn((owner: string, repo: string, sha: string) =>
|
||||
Promise.resolve(
|
||||
options?.commits?.[sha] ?? {
|
||||
sha,
|
||||
message: `commit ${sha}`,
|
||||
},
|
||||
),
|
||||
),
|
||||
} satisfies Pick<
|
||||
GiteaClient,
|
||||
'healthSummary' | 'listBranches' | 'listTags' | 'getCommit'
|
||||
>;
|
||||
const auth = {
|
||||
listAllowedProjectKeys: jest.fn(() => Promise.resolve([project.key])),
|
||||
requireProjectPermission: jest.fn(() => Promise.resolve()),
|
||||
@@ -74,16 +86,37 @@ describe('ProjectsService', () => {
|
||||
giteaConfigured: true,
|
||||
branches: [{ name: 'feature/devops-platform', commitSha: 'abc123' }],
|
||||
tags: [{ name: 'v2026.06.11.1', commitSha: 'def456' }],
|
||||
commits: {
|
||||
abc123: { sha: 'abc123', message: 'feat: add platform refs' },
|
||||
def456: { sha: 'def456', message: 'chore: tag release' },
|
||||
},
|
||||
});
|
||||
|
||||
const refs = await service.listProjectRefs(project.key);
|
||||
|
||||
expect(refs).toEqual({
|
||||
source: 'gitea',
|
||||
branches: [{ name: 'feature/devops-platform', commitSha: 'abc123' }],
|
||||
tags: [{ name: 'v2026.06.11.1', commitSha: 'def456' }],
|
||||
branches: [
|
||||
{
|
||||
name: 'feature/devops-platform',
|
||||
commitSha: 'abc123',
|
||||
commit: { sha: 'abc123', message: 'feat: add platform refs' },
|
||||
},
|
||||
],
|
||||
tags: [
|
||||
{
|
||||
name: 'v2026.06.11.1',
|
||||
commitSha: 'def456',
|
||||
commit: { sha: 'def456', message: 'chore: tag release' },
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(gitea.listBranches).toHaveBeenCalledWith('my-project', 'access-manage');
|
||||
expect(gitea.getCommit).toHaveBeenCalledWith(
|
||||
'my-project',
|
||||
'access-manage',
|
||||
'abc123',
|
||||
);
|
||||
});
|
||||
|
||||
it('raises a not found error for unknown projects', async () => {
|
||||
|
||||
Reference in New Issue
Block a user