Skip to content

Commit

Permalink
fix: single cache instance
Browse files Browse the repository at this point in the history
  • Loading branch information
djabarovgeorge committed Dec 7, 2022
1 parent efcd2e1 commit a2eb759
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
21 changes: 6 additions & 15 deletions apps/api/e2e/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import { DalService } from '@novu/dal';
import { testServer } from '@novu/testing';
import * as sinon from 'sinon';
import { bootstrap } from '../src/bootstrap';
import { CacheService, ICacheService } from '@novu/dal';
import { CacheService } from '@novu/dal';

const dalService = new DalService();

export const testCacheService = new CacheService({
cachePort: process.env.REDIS_CACHE_PORT,
cacheHost: process.env.REDIS_CACHE_HOST,
});

before(async () => {
await testServer.create(await bootstrap());
await dalService.connect(process.env.MONGO_URL);
testCacheService().connect();
});

after(async () => {
Expand All @@ -26,16 +30,3 @@ after(async () => {
afterEach(() => {
sinon.restore();
});

export function testCacheService() {
let cacheService: ICacheService;

function connect() {
cacheService = new CacheService({
cachePort: process.env.REDIS_CACHE_PORT,
cacheHost: process.env.REDIS_CACHE_HOST,
});
}

return { connect, cacheService };
}
2 changes: 1 addition & 1 deletion apps/api/src/app/change/e2e/promote-changes.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { testCacheService } from '../../../../e2e/setup';

describe('Promote changes', () => {
let session: UserSession;
const cacheService = testCacheService().cacheService;
const cacheService = testCacheService;
const changeRepository: ChangeRepository = new ChangeRepository();
const notificationTemplateRepository = new NotificationTemplateRepository(cacheService);
const messageTemplateRepository: MessageTemplateRepository = new MessageTemplateRepository();
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/events/e2e/process-subscriber.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Trigger event - process subscriber /v1/events/trigger (POST)', functio
let subscriber: SubscriberEntity;
let subscriberService: SubscribersService;

const cacheService = testCacheService().cacheService;
const cacheService = testCacheService;
const subscriberRepository = new SubscriberRepository(cacheService);
const messageRepository = new MessageRepository(cacheService);
const notificationTemplateRepository = new NotificationTemplateRepository(cacheService);
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/events/e2e/trigger-event.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { testCacheService } from '../../../../e2e/setup';
const axiosInstance = axios.create();

describe('Trigger event - /v1/events/trigger (POST)', function () {
const cacheService = testCacheService().cacheService;
const cacheService = testCacheService;
let session: UserSession;
let template: NotificationTemplateEntity;
let subscriber: SubscriberEntity;
Expand Down

0 comments on commit a2eb759

Please sign in to comment.