Modify plugin sonarqube's APIs to take object as parameter
to make the API more easy to extend. Signed-off-by: Neemys <36508659+Neemys@users.noreply.github.com>
This commit is contained in:
@@ -38,8 +38,11 @@ export const sonarQubeApiRef = createApiRef<SonarQubeApi>({
|
||||
});
|
||||
|
||||
export type SonarQubeApi = {
|
||||
getFindingSummary(
|
||||
projectInstance?: string,
|
||||
componentKey?: string,
|
||||
): Promise<FindingSummary | undefined>;
|
||||
getFindingSummary({
|
||||
componentKey,
|
||||
projectInstance,
|
||||
}: {
|
||||
componentKey?: string;
|
||||
projectInstance?: string;
|
||||
}): Promise<FindingSummary | undefined>;
|
||||
};
|
||||
|
||||
@@ -124,7 +124,9 @@ describe('SonarQubeClient', () => {
|
||||
identityApi: identityApiAuthenticated,
|
||||
});
|
||||
|
||||
const summary = await client.getFindingSummary('our:service');
|
||||
const summary = await client.getFindingSummary({
|
||||
componentKey: 'our:service',
|
||||
});
|
||||
expect(summary).toEqual(
|
||||
expect.objectContaining({
|
||||
lastAnalysis: '2020-01-01T00:00:00Z',
|
||||
@@ -199,7 +201,10 @@ describe('SonarQubeClient', () => {
|
||||
identityApi: identityApiAuthenticated,
|
||||
});
|
||||
|
||||
const summary = await client.getFindingSummary('our:service', 'custom');
|
||||
const summary = await client.getFindingSummary({
|
||||
componentKey: 'our:service',
|
||||
projectInstance: 'custom',
|
||||
});
|
||||
|
||||
expect(summary).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -241,7 +246,9 @@ describe('SonarQubeClient', () => {
|
||||
discoveryApi,
|
||||
identityApi: identityApiAuthenticated,
|
||||
});
|
||||
const summary = await client.getFindingSummary('our:service');
|
||||
const summary = await client.getFindingSummary({
|
||||
componentKey: 'our:service',
|
||||
});
|
||||
|
||||
expect(summary?.lastAnalysis).toBe('2020-01-01T00:00:00Z');
|
||||
});
|
||||
@@ -267,7 +274,9 @@ describe('SonarQubeClient', () => {
|
||||
discoveryApi,
|
||||
identityApi: identityApiGuest,
|
||||
});
|
||||
const summary = await client.getFindingSummary('our:service');
|
||||
const summary = await client.getFindingSummary({
|
||||
componentKey: 'our:service',
|
||||
});
|
||||
|
||||
expect(summary?.lastAnalysis).toBe('2020-01-01T00:00:00Z');
|
||||
});
|
||||
|
||||
@@ -56,10 +56,13 @@ export class SonarQubeClient implements SonarQubeApi {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async getFindingSummary(
|
||||
componentKey?: string,
|
||||
projectInstance?: string,
|
||||
): Promise<FindingSummary | undefined> {
|
||||
async getFindingSummary({
|
||||
componentKey,
|
||||
projectInstance,
|
||||
}: {
|
||||
componentKey?: string;
|
||||
projectInstance?: string;
|
||||
} = {}): Promise<FindingSummary | undefined> {
|
||||
if (!componentKey) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user