Skip to content

Commit 3496c4a

Browse files
committed
Refactoring some tests
1 parent 34f4061 commit 3496c4a

File tree

8 files changed

+69
-101
lines changed

8 files changed

+69
-101
lines changed

redisinsight/api/src/__mocks__/rdi.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export class MockRdiClient extends ApiRdiClient {
2323

2424
public getPipeline = jest.fn();
2525

26-
public getTemplate = jest.fn();
26+
public getConfigTemplate = jest.fn();
27+
28+
public getJobTemplate = jest.fn();
2729

2830
public getStrategies = jest.fn();
2931

@@ -118,3 +120,21 @@ export const mockRdiClientProvider = jest.fn(() => ({
118120
export const mockRdiClientFactory = jest.fn(() => ({
119121
createClient: jest.fn(),
120122
}));
123+
124+
export const mockRdiClientStorage = jest.fn(() => ({
125+
getByMetadata: jest.fn(),
126+
set: jest.fn(),
127+
delete: jest.fn(),
128+
deleteManyByRdiId: jest.fn(),
129+
}));
130+
131+
export const mockRdiPipelineAnalytics = jest.fn(() => ({
132+
sendRdiPipelineFetched: jest.fn(),
133+
sendRdiPipelineFetchFailed: jest.fn(),
134+
sendRdiPipelineDeployed: jest.fn(),
135+
sendRdiPipelineDeployFailed: jest.fn(),
136+
}));
137+
138+
export const mockRdiAnalytics = jest.fn(() => ({
139+
sendRdiInstanceDeleted: jest.fn(),
140+
}));

redisinsight/api/src/constants/custom-error-codes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ export enum CustomErrorCodes {
5858
RdiUnauthorized = 11_402,
5959
RdiInternalServerError = 11_403,
6060
RdiValidationError = 11_404,
61+
RdiNotFound = 11_405,
6162
}

redisinsight/api/src/modules/rdi/client/api.rdi.client.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ describe('ApiRdiClient', () => {
117117
const expectedResponse = {
118118
transformations: {
119119
status: RdiDyRunJobStatus.Success,
120-
// data: {},
121-
// error: ''
122120
},
123121
commands: {
124122
status: RdiDyRunJobStatus.Success,

redisinsight/api/src/modules/rdi/exceptions/rdi-pipeline.not-found.exception.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class RdiPipelineNotFoundException extends HttpException {
1111
message,
1212
statusCode: HttpStatus.NOT_FOUND,
1313
error: 'RdiNotFound',
14-
errorCode: CustomErrorCodes.ConvAiNotFound,
14+
errorCode: CustomErrorCodes.RdiNotFound,
1515
details: options?.details,
1616
};
1717
super(response, response.statusCode, options);

redisinsight/api/src/modules/rdi/exceptions/rdi-pipiline.error.handler.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe('wrapRdiPipelineError', () => {
123123
message: result.message,
124124
statusCode: HttpStatus.NOT_FOUND,
125125
error: 'RdiNotFound',
126-
errorCode: CustomErrorCodes.ConvAiNotFound,
126+
errorCode: CustomErrorCodes.RdiNotFound,
127127
details: errorDetails.details,
128128
});
129129
});

redisinsight/api/src/modules/rdi/providers/rdi.client.provider.spec.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { NotFoundException } from '@nestjs/common';
66
import { RdiClientMetadata } from 'src/modules/rdi/models';
77
import { RdiClient } from 'src/modules/rdi/client/rdi.client';
88
import {
9-
MockType, generateMockRdiClient, mockRdi, mockRdiRepository,
9+
MockType, generateMockRdiClient, mockRdi, mockRdiClientFactory, mockRdiClientStorage, mockRdiRepository,
1010
} from 'src/__mocks__';
1111
import { RdiClientProvider } from './rdi.client.provider';
1212

@@ -26,18 +26,11 @@ describe('RdiClientProvider', () => {
2626
},
2727
{
2828
provide: RdiClientStorage,
29-
useFactory: jest.fn(() => ({
30-
getByMetadata: jest.fn(),
31-
set: jest.fn(),
32-
delete: jest.fn(),
33-
deleteManyByRdiId: jest.fn(),
34-
})),
29+
useFactory: mockRdiClientStorage,
3530
},
3631
{
3732
provide: RdiClientFactory,
38-
useFactory: jest.fn(() => ({
39-
createClient: jest.fn(),
40-
})),
33+
useFactory: mockRdiClientFactory,
4134
},
4235
],
4336
}).compile();

0 commit comments

Comments
 (0)