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 ErrorTimedOutFileOperationsTask from "./ErrorTimedOutFileOperationsTask";
|
||||
|
||||
@@ -9,12 +9,15 @@ setupTestDatabase();
|
||||
|
||||
describe("ErrorTimedOutFileOperationsTask", () => {
|
||||
it("should error exports older than 12 hours", async () => {
|
||||
const team = await buildTeam();
|
||||
await buildFileOperation({
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Creating,
|
||||
createdAt: subDays(new Date(), 15),
|
||||
});
|
||||
await buildFileOperation({
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Complete,
|
||||
});
|
||||
@@ -25,6 +28,7 @@ describe("ErrorTimedOutFileOperationsTask", () => {
|
||||
|
||||
const data = await FileOperation.count({
|
||||
where: {
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Error,
|
||||
},
|
||||
@@ -33,7 +37,9 @@ describe("ErrorTimedOutFileOperationsTask", () => {
|
||||
});
|
||||
|
||||
it("should not error exports created less than 12 hours ago", async () => {
|
||||
const team = await buildTeam();
|
||||
await buildFileOperation({
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Creating,
|
||||
});
|
||||
@@ -43,6 +49,7 @@ describe("ErrorTimedOutFileOperationsTask", () => {
|
||||
|
||||
const data = await FileOperation.count({
|
||||
where: {
|
||||
teamId: team.id,
|
||||
type: FileOperationType.Export,
|
||||
state: FileOperationState.Error,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user