From 39066b88bc449d3274721146ba3e4d37a05d9762 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Mon, 31 Mar 2025 20:21:09 -0700 Subject: [PATCH] have teardown clear all data in redis before starting next test --- src/repositories/RedisNotificationRepository.ts | 6 +++++- test/repositories/NotificationRepositorySharedTests.test.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/repositories/RedisNotificationRepository.ts b/src/repositories/RedisNotificationRepository.ts index a1522ed..76d5765 100644 --- a/src/repositories/RedisNotificationRepository.ts +++ b/src/repositories/RedisNotificationRepository.ts @@ -22,7 +22,7 @@ export class RedisNotificationRepository implements NotificationRepository { } get isReady() { - return this.redisClient.isReady + return this.redisClient.isReady; } public async connect() { @@ -33,6 +33,10 @@ export class RedisNotificationRepository implements NotificationRepository { await this.redisClient.disconnect(); } + public async clearAllData() { + await this.redisClient.flushAll(); + } + public async addOrUpdateNotification(notification: ScheduledNotification): Promise { } diff --git a/test/repositories/NotificationRepositorySharedTests.test.ts b/test/repositories/NotificationRepositorySharedTests.test.ts index 282776a..6205833 100644 --- a/test/repositories/NotificationRepositorySharedTests.test.ts +++ b/test/repositories/NotificationRepositorySharedTests.test.ts @@ -28,6 +28,7 @@ class RedisNotificationRepositoryHolder implements RepositoryHolder { } teardown = async () => { if (this.repo) { + await this.repo.clearAllData(); await this.repo.disconnect(); } }