chore: Improve perf of server tests (#5785)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { subDays } from "date-fns";
|
||||
import { FileOperationState, FileOperationType } from "@shared/types";
|
||||
import { FileOperation } from "@server/models";
|
||||
import { buildFileOperation } from "@server/test/factories";
|
||||
import { buildFileOperation, buildTeam } from "@server/test/factories";
|
||||
import { setupTestDatabase } from "@server/test/support";
|
||||
import CleanupExpiredFileOperationsTask from "./CleanupExpiredFileOperationsTask";
|
||||
|
||||
@@ -9,12 +9,15 @@ setupTestDatabase();
|
||||
|
||||
describe("CleanupExpiredFileOperationsTask", () => {
|
||||
it("should expire exports older than 15 days ago", async () => {
|
||||
const team = await buildTeam();
|
||||
await buildFileOperation({
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Complete,
|
||||
createdAt: subDays(new Date(), 15),
|
||||
});
|
||||
await buildFileOperation({
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Complete,
|
||||
});
|
||||
@@ -25,6 +28,7 @@ describe("CleanupExpiredFileOperationsTask", () => {
|
||||
|
||||
const data = await FileOperation.count({
|
||||
where: {
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Expired,
|
||||
},
|
||||
@@ -33,12 +37,15 @@ describe("CleanupExpiredFileOperationsTask", () => {
|
||||
});
|
||||
|
||||
it("should not expire exports made less than 15 days ago", async () => {
|
||||
const team = await buildTeam();
|
||||
await buildFileOperation({
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Complete,
|
||||
createdAt: subDays(new Date(), 14),
|
||||
});
|
||||
await buildFileOperation({
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Complete,
|
||||
});
|
||||
@@ -48,6 +55,7 @@ describe("CleanupExpiredFileOperationsTask", () => {
|
||||
|
||||
const data = await FileOperation.count({
|
||||
where: {
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Expired,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user