Revert "bugfix: Proper error thrown in plugin-azure-devops-backend when gitRepository is not found."

This reverts commit 88191bb54e.

Signed-off-by: NIKUNJ LALITKUMAR HUDKA <nikunjhudka123@gmail.com>
This commit is contained in:
NIKUNJ LALITKUMAR HUDKA
2024-04-20 14:18:23 -03:00
parent b8466a40f8
commit 82214e72c9
3 changed files with 0 additions and 62 deletions
-5
View File
@@ -1,5 +0,0 @@
---
'@backstage/plugin-azure-devops-backend': minor
---
Fixed bug in plugin-azure-devops-backend where proper error was not thrown when gitRepository was not found.
@@ -465,43 +465,6 @@ describe('AzureDevOpsApi', () => {
]);
});
it('should throw error when gitRepository is undefined', async () => {
const mockApi = {
getGitApi: jest.fn().mockReturnValue({}),
serverUrl: 'serverUrl',
};
(WebApi as unknown as jest.Mock).mockImplementation(() => mockApi);
const api = AzureDevOpsApi.fromConfig(mockConfig, {
logger: mockLogger,
urlReader: mockUrlReader,
});
const pullRequestOptions: PullRequestOptions = {
top: 10,
status: PullRequestStatus.Active,
};
api.getGitRepository = jest.fn().mockResolvedValue(undefined);
const temp = async () => {
try {
await api.getPullRequests('project', 'repo', pullRequestOptions);
return null;
} catch (error) {
return error;
}
};
const error = await temp();
expect(error).toHaveProperty(
'message',
'No repository found for Project "project" with Repository "repo" on host "undefined" under organization "undefined".',
);
});
it('should get build definitions', async () => {
const mockBuilds: Build[] = [
{
@@ -231,11 +231,6 @@ export class AzureDevOpsApi {
host,
org,
);
if (!gitRepository) {
throw new Error(
`No repository found for Project "${projectName}" with Repository "${repoName}" on host "${host}" under organization "${org}".`,
);
}
const buildList = await this.getBuildList(
projectName,
gitRepository.id as string,
@@ -267,11 +262,6 @@ export class AzureDevOpsApi {
host,
org,
);
if (!gitRepository) {
throw new Error(
`No repository found for Project "${projectName}" with Repository "${repoName}" on host "${host}" under organization "${org}".`,
);
}
const webApi = await this.getWebApi(host, org);
const client = await webApi.getGitApi();
const tagRefs: GitRef[] = await client.getRefs(
@@ -314,11 +304,6 @@ export class AzureDevOpsApi {
host,
org,
);
if (!gitRepository) {
throw new Error(
`No repository found for Project "${projectName}" with Repository "${repoName}" on host "${host}" under organization "${org}".`,
);
}
const webApi = await this.getWebApi(host, org);
const client = await webApi.getGitApi();
const searchCriteria: GitPullRequestSearchCriteria = {
@@ -529,11 +514,6 @@ export class AzureDevOpsApi {
host,
org,
);
if (!gitRepository) {
throw new Error(
`No repository found for Project "${projectName}" with Repository "${repoName}" on host "${host}" under organization "${org}".`,
);
}
repoId = gitRepository.id;
}