Skip to content

Commit

Permalink
Fixes failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
macnablocky committed Jun 25, 2024
1 parent 33db190 commit 78d64e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import { HCaptchaVerifyGateway } from '../../integrations/h-captcha-labeling/h-c
export class HCaptchaService {
BAD_REQUEST = 400;
OK = 200;
DAILY_HMT_SPENT_CACHE_KEY = 'daily-hmt-spent-cache';
get dailyHmtSpentCacheKey() {
return 'daily-hmt-spent-cache';
}
private readonly logger = new Logger(HCaptchaService.name);
constructor(
private configService: EnvironmentConfigService,
Expand Down Expand Up @@ -72,12 +74,12 @@ export class HCaptchaService {
): Promise<DailyHmtSpentResponse> {
this.checkIfHcaptchaSitekeyPresent(command.siteKey);
let dailyHmtSpent = await this.cacheManager.get<DailyHmtSpentResponse>(
this.DAILY_HMT_SPENT_CACHE_KEY,
this.dailyHmtSpentCacheKey
);
if (!dailyHmtSpent) {
dailyHmtSpent = await this.hCaptchaLabelingGateway.fetchDailyHmtSpent();
await this.cacheManager.set(
this.DAILY_HMT_SPENT_CACHE_KEY,
this.dailyHmtSpentCacheKey,
dailyHmtSpent,
this.configService.cacheTtlDailyHmtSpent,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ describe('HCaptchaService', () => {
const result = await service.getDailyHmtSpent(command);
expect(result).toEqual(dailyHmtSpentResponseFixture);
expect(cacheManager.set).toHaveBeenCalledWith(
service.dailyHmtSpentCacheKey,
dailyHmtSpentResponseFixture,
configService.cacheTtlDailyHmtSpent,
);
Expand Down

0 comments on commit 78d64e1

Please sign in to comment.