mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-19 17:00:30 +00:00
Remove clearAllData from BaseRedisRepository and update tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, jest } from "@jest/globals";
|
||||
import { createClient, RedisClientType } from "redis";
|
||||
import { InMemoryNotificationRepository } from "../InMemoryNotificationRepository";
|
||||
import { NotificationEvent, NotificationRepository } from "../NotificationRepository";
|
||||
import { RedisNotificationRepository } from "../RedisNotificationRepository";
|
||||
@@ -19,17 +20,21 @@ class InMemoryRepositoryHolder implements RepositoryHolder {
|
||||
|
||||
class RedisNotificationRepositoryHolder implements RepositoryHolder {
|
||||
repo: RedisNotificationRepository | undefined;
|
||||
redisClient: RedisClientType | undefined;
|
||||
|
||||
name = 'RedisNotificationRepository';
|
||||
factory = async () => {
|
||||
this.repo = new RedisNotificationRepository();
|
||||
await this.repo.connect();
|
||||
this.redisClient = createClient({
|
||||
url: process.env.REDIS_URL,
|
||||
});
|
||||
await this.redisClient.connect();
|
||||
this.repo = new RedisNotificationRepository(this.redisClient);
|
||||
return this.repo;
|
||||
}
|
||||
teardown = async () => {
|
||||
if (this.repo) {
|
||||
await this.repo.clearAllData();
|
||||
await this.repo.disconnect();
|
||||
if (this.redisClient) {
|
||||
await this.redisClient.flushAll();
|
||||
await this.redisClient.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user