test: 完善测试用例
This commit is contained in:
parent
256878890b
commit
5ed17cc04b
@ -1,4 +1,5 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { RedisService } from 'nestjs-redis';
|
||||||
import { RedisMutexService } from './redis-mutex.service';
|
import { RedisMutexService } from './redis-mutex.service';
|
||||||
|
|
||||||
describe('RedisMutexService', () => {
|
describe('RedisMutexService', () => {
|
||||||
@ -6,7 +7,13 @@ describe('RedisMutexService', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
providers: [RedisMutexService],
|
providers: [
|
||||||
|
RedisMutexService,
|
||||||
|
{
|
||||||
|
provide: RedisService,
|
||||||
|
useValue: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
service = module.get<RedisMutexService>(RedisMutexService);
|
service = module.get<RedisMutexService>(RedisMutexService);
|
||||||
|
@ -12,6 +12,7 @@ import { readFile } from 'fs/promises';
|
|||||||
import { getLoggerToken, PinoLogger } from 'nestjs-pino';
|
import { getLoggerToken, PinoLogger } from 'nestjs-pino';
|
||||||
import { Nack } from '@golevelup/nestjs-rabbitmq';
|
import { Nack } from '@golevelup/nestjs-rabbitmq';
|
||||||
import { getInstanceName } from '../commons/utils/rabbit-mq';
|
import { getInstanceName } from '../commons/utils/rabbit-mq';
|
||||||
|
import { RedisMutexService } from '../commons/redis-mutex/redis-mutex.service';
|
||||||
|
|
||||||
const getTest1Project = () =>
|
const getTest1Project = () =>
|
||||||
({
|
({
|
||||||
@ -52,6 +53,14 @@ describe('ReposService', () => {
|
|||||||
provide: getLoggerToken(ReposService.name),
|
provide: getLoggerToken(ReposService.name),
|
||||||
useValue: new PinoLogger({}),
|
useValue: new PinoLogger({}),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: RedisMutexService,
|
||||||
|
useValue: {
|
||||||
|
lock: jest.fn(() =>
|
||||||
|
Promise.resolve(() => Promise.resolve(undefined)),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user