From afe828fc1a06050fa11e38b82d0f227683172d82 Mon Sep 17 00:00:00 2001 From: Ravinou Date: Sun, 20 Apr 2025 21:42:54 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=9A=A1=20update=20cron=20message?= =?UTF-8?q?=20to=20be=20consistent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/api/v1/cron/status.test.ts | 2 +- pages/api/v1/cron/status.ts | 2 +- pages/api/v1/cron/storage.test.ts | 7 ++++--- pages/api/v1/cron/storage.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pages/api/v1/cron/status.test.ts b/pages/api/v1/cron/status.test.ts index a4de54e..a89d3f1 100644 --- a/pages/api/v1/cron/status.test.ts +++ b/pages/api/v1/cron/status.test.ts @@ -152,7 +152,7 @@ describe('Cronjob API Handler', () => { expect(res._getStatusCode()).toBe(200); expect(res._getJSONData()).toEqual({ status: 200, - message: 'Status cron executed successfully.', + message: 'Status cron executed successfully', }); expect(ConfigService.updateRepoList).toHaveBeenCalled(); }); diff --git a/pages/api/v1/cron/status.ts b/pages/api/v1/cron/status.ts index 49d890b..5ca9c8e 100644 --- a/pages/api/v1/cron/status.ts +++ b/pages/api/v1/cron/status.ts @@ -96,7 +96,7 @@ export default async function handler( } await ConfigService.updateRepoList(updatedRepoList); - return ApiResponse.success(res, 'Status cron executed successfully.'); + return ApiResponse.success(res, 'Status cron executed successfully'); } catch (error) { console.log(error); if (error instanceof Error && error.message === 'The check status service is already running') { diff --git a/pages/api/v1/cron/storage.test.ts b/pages/api/v1/cron/storage.test.ts index 79578d4..bf2c429 100644 --- a/pages/api/v1/cron/storage.test.ts +++ b/pages/api/v1/cron/storage.test.ts @@ -1,6 +1,7 @@ import handler from '~/pages/api/v1/cron/storage'; import { createMocks } from 'node-mocks-http'; import { ConfigService, ShellService } from '~/services'; +import { Repository } from '~/types'; vi.mock('~/services'); @@ -56,7 +57,7 @@ describe('GET /api/cronjob/getStorageUsed', () => { const mockRepoList = [ { repositoryName: 'repo1', storageUsed: 0 }, { repositoryName: 'repo2', storageUsed: 0 }, - ]; + ] as Repository[]; const mockStorageUsed = [ { name: 'repo1', size: 100 }, { name: 'repo2', size: 200 }, @@ -76,7 +77,7 @@ describe('GET /api/cronjob/getStorageUsed', () => { await handler(req, res); expect(res._getStatusCode()).toBe(200); - expect(res._getData()).toContain('Storage cron has been executed'); + expect(res._getData()).toContain('Storage cron executed successfully'); expect(ConfigService.updateRepoList).toHaveBeenCalledWith([ { repositoryName: 'repo1', storageUsed: 100 }, { repositoryName: 'repo2', storageUsed: 200 }, @@ -102,7 +103,7 @@ describe('GET /api/cronjob/getStorageUsed', () => { const mockRepoList = [ { repositoryName: 'repo1', storageUsed: 0 }, { repositoryName: 'repo2', storageUsed: 0 }, - ]; + ] as Repository[]; const mockStorageUsed = [{ name: 'repo1', size: 100 }]; vi.mocked(ConfigService.getRepoList).mockResolvedValue(mockRepoList); diff --git a/pages/api/v1/cron/storage.ts b/pages/api/v1/cron/storage.ts index 6dc9769..2740954 100644 --- a/pages/api/v1/cron/storage.ts +++ b/pages/api/v1/cron/storage.ts @@ -38,7 +38,7 @@ export default async function handler( }); await ConfigService.updateRepoList(updatedRepoList); - return ApiResponse.success(res, 'Storage cron has been executed.'); + return ApiResponse.success(res, 'Storage cron executed successfully'); } catch (error) { console.log(error); if (error instanceof Error && error.message === 'The storage used service is already running') {