mirror of
https://github.com/Ravinou/borgwarehouse
synced 2026-03-14 14:25:46 +01:00
refactor: ⚡ update cron message to be consistent
This commit is contained in:
parent
5567cddfdb
commit
afe828fc1a
4 changed files with 7 additions and 6 deletions
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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') {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue