From 5b658984a5a390ad1ef25916acbdd1adfa7c5b5b Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Tue, 28 May 2024 14:51:55 -1000 Subject: [PATCH] refactor: :white_check_mark: Only delete old test users once at preload --- bunfig.toml | 3 +++ drizzle/db.ts | 4 ++-- server/api/api/auth/login/index.test.ts | 8 +------- server/api/api/auth/reset/index.test.ts | 8 +------- server/api/api/v1/accounts/:id/block.test.ts | 8 +------- server/api/api/v1/accounts/:id/follow.test.ts | 8 +------- server/api/api/v1/accounts/:id/followers.test.ts | 8 +------- server/api/api/v1/accounts/:id/following.test.ts | 8 +------- server/api/api/v1/accounts/:id/index.test.ts | 9 +-------- server/api/api/v1/accounts/:id/mute.test.ts | 8 +------- server/api/api/v1/accounts/:id/statuses.test.ts | 9 +-------- server/api/api/v1/accounts/:id/unmute.test.ts | 8 +------- server/api/api/v1/accounts/index.test.ts | 7 +------ server/api/api/v1/accounts/lookup/index.test.ts | 8 +------- server/api/api/v1/accounts/search/index.test.ts | 8 +------- server/api/api/v1/markers/index.test.ts | 11 ++--------- server/api/api/v1/mutes/index.test.ts | 8 +------- server/api/api/v1/notifications/:id/dismiss.test.ts | 8 +------- server/api/api/v1/notifications/:id/index.test.ts | 8 +------- server/api/api/v1/notifications/clear/index.test.ts | 8 +------- .../v1/notifications/destroy_multiple/index.test.ts | 9 +-------- server/api/api/v1/notifications/index.test.ts | 9 +-------- server/api/api/v1/sso/:id/index.test.ts | 8 +------- server/api/api/v1/sso/index.test.ts | 8 +------- server/api/api/v1/statuses/:id/favourited_by.test.ts | 9 +-------- server/api/api/v1/statuses/:id/reblogged_by.test.ts | 9 +-------- server/api/api/v1/statuses/index.test.ts | 8 +------- server/api/api/v1/timelines/home.test.ts | 9 +-------- server/api/api/v1/timelines/public.test.ts | 9 +-------- tests/setup.ts | 5 +++++ 30 files changed, 38 insertions(+), 200 deletions(-) create mode 100644 tests/setup.ts diff --git a/bunfig.toml b/bunfig.toml index bea1efe1..43df4271 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -1,2 +1,5 @@ [install.scopes] "@jsr" = "https://npm.jsr.io" + +[test] +preload = ["./tests/setup.ts"] diff --git a/drizzle/db.ts b/drizzle/db.ts index 83d75de2..ec587498 100644 --- a/drizzle/db.ts +++ b/drizzle/db.ts @@ -1,6 +1,6 @@ import { drizzle } from "drizzle-orm/node-postgres"; import { migrate } from "drizzle-orm/postgres-js/migrator"; -import { LogLevel, type LogManager, type MultiLogManager } from "log-manager"; +import { LogLevel, LogManager, type MultiLogManager } from "log-manager"; import { Client } from "pg"; import { config } from "~/packages/config-manager"; import * as schema from "./schema"; @@ -14,7 +14,7 @@ export const client = new Client({ }); export const setupDatabase = async ( - logger: LogManager | MultiLogManager, + logger: LogManager | MultiLogManager = new LogManager(Bun.stdout), info = true, ) => { try { diff --git a/server/api/api/auth/login/index.test.ts b/server/api/api/auth/login/index.test.ts index 801ec973..4fa72de7 100644 --- a/server/api/api/auth/login/index.test.ts +++ b/server/api/api/auth/login/index.test.ts @@ -4,15 +4,9 @@ import { eq } from "drizzle-orm"; import { db } from "~drizzle/db"; import { Applications } from "~drizzle/schema"; import { config } from "~packages/config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, deleteUsers, passwords } = await getTestUsers(1); // Create application diff --git a/server/api/api/auth/reset/index.test.ts b/server/api/api/auth/reset/index.test.ts index 228feb22..18e93a2c 100644 --- a/server/api/api/auth/reset/index.test.ts +++ b/server/api/api/auth/reset/index.test.ts @@ -4,15 +4,9 @@ import { eq } from "drizzle-orm"; import { db } from "~drizzle/db"; import { Applications } from "~drizzle/schema"; import { config } from "~packages/config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, deleteUsers, passwords } = await getTestUsers(1); const token = randomBytes(32).toString("hex"); const newPassword = randomBytes(16).toString("hex"); diff --git a/server/api/api/v1/accounts/:id/block.test.ts b/server/api/api/v1/accounts/:id/block.test.ts index cc174083..b5011b97 100644 --- a/server/api/api/v1/accounts/:id/block.test.ts +++ b/server/api/api/v1/accounts/:id/block.test.ts @@ -1,15 +1,9 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Relationship as APIRelationship } from "~types/mastodon/relationship"; import { meta } from "./block"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(2); afterAll(async () => { diff --git a/server/api/api/v1/accounts/:id/follow.test.ts b/server/api/api/v1/accounts/:id/follow.test.ts index 170f80e1..6f952a88 100644 --- a/server/api/api/v1/accounts/:id/follow.test.ts +++ b/server/api/api/v1/accounts/:id/follow.test.ts @@ -1,15 +1,9 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Relationship as APIRelationship } from "~types/mastodon/relationship"; import { meta } from "./follow"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(2); afterAll(async () => { diff --git a/server/api/api/v1/accounts/:id/followers.test.ts b/server/api/api/v1/accounts/:id/followers.test.ts index ef126241..d4fb209e 100644 --- a/server/api/api/v1/accounts/:id/followers.test.ts +++ b/server/api/api/v1/accounts/:id/followers.test.ts @@ -1,15 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Account as APIAccount } from "~types/mastodon/account"; import { meta } from "./followers"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); afterAll(async () => { diff --git a/server/api/api/v1/accounts/:id/following.test.ts b/server/api/api/v1/accounts/:id/following.test.ts index 684c6936..74b73721 100644 --- a/server/api/api/v1/accounts/:id/following.test.ts +++ b/server/api/api/v1/accounts/:id/following.test.ts @@ -1,15 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Account as APIAccount } from "~types/mastodon/account"; import { meta } from "./following"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); afterAll(async () => { diff --git a/server/api/api/v1/accounts/:id/index.test.ts b/server/api/api/v1/accounts/:id/index.test.ts index c1985176..e48777ff 100644 --- a/server/api/api/v1/accounts/:id/index.test.ts +++ b/server/api/api/v1/accounts/:id/index.test.ts @@ -1,16 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import type { Account as APIAccount } from "~types/mastodon/account"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); const timeline = (await getTestStatuses(40, users[0])).toReversed(); diff --git a/server/api/api/v1/accounts/:id/mute.test.ts b/server/api/api/v1/accounts/:id/mute.test.ts index c685e0fc..92ebdb25 100644 --- a/server/api/api/v1/accounts/:id/mute.test.ts +++ b/server/api/api/v1/accounts/:id/mute.test.ts @@ -1,15 +1,9 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Relationship as APIRelationship } from "~types/mastodon/relationship"; import { meta } from "./mute"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(2); afterAll(async () => { diff --git a/server/api/api/v1/accounts/:id/statuses.test.ts b/server/api/api/v1/accounts/:id/statuses.test.ts index 41ba5882..0acec7cd 100644 --- a/server/api/api/v1/accounts/:id/statuses.test.ts +++ b/server/api/api/v1/accounts/:id/statuses.test.ts @@ -1,16 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import type { Status as APIStatus } from "~types/mastodon/status"; import { meta } from "./statuses"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); const timeline = (await getTestStatuses(40, users[1])).toReversed(); const timeline2 = (await getTestStatuses(40, users[2])).toReversed(); diff --git a/server/api/api/v1/accounts/:id/unmute.test.ts b/server/api/api/v1/accounts/:id/unmute.test.ts index 40bfe2d6..91501955 100644 --- a/server/api/api/v1/accounts/:id/unmute.test.ts +++ b/server/api/api/v1/accounts/:id/unmute.test.ts @@ -1,15 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Relationship as APIRelationship } from "~types/mastodon/relationship"; import { meta } from "./unmute"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(2); afterAll(async () => { diff --git a/server/api/api/v1/accounts/index.test.ts b/server/api/api/v1/accounts/index.test.ts index 8687a21a..c71fa35d 100644 --- a/server/api/api/v1/accounts/index.test.ts +++ b/server/api/api/v1/accounts/index.test.ts @@ -11,12 +11,7 @@ import { config } from "config-manager"; import { eq } from "drizzle-orm"; import { db } from "~drizzle/db"; import { Users } from "~drizzle/schema"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import type { Account as APIAccount } from "~types/mastodon/account"; import { meta } from "./index"; diff --git a/server/api/api/v1/accounts/lookup/index.test.ts b/server/api/api/v1/accounts/lookup/index.test.ts index a5a9e653..3d80647b 100644 --- a/server/api/api/v1/accounts/lookup/index.test.ts +++ b/server/api/api/v1/accounts/lookup/index.test.ts @@ -1,15 +1,9 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Account as APIAccount } from "~types/mastodon/account"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); afterAll(async () => { diff --git a/server/api/api/v1/accounts/search/index.test.ts b/server/api/api/v1/accounts/search/index.test.ts index 02351763..84bc6779 100644 --- a/server/api/api/v1/accounts/search/index.test.ts +++ b/server/api/api/v1/accounts/search/index.test.ts @@ -1,15 +1,9 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Account as APIAccount } from "~types/mastodon/account"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); afterAll(async () => { diff --git a/server/api/api/v1/markers/index.test.ts b/server/api/api/v1/markers/index.test.ts index 7b722804..255f8e6b 100644 --- a/server/api/api/v1/markers/index.test.ts +++ b/server/api/api/v1/markers/index.test.ts @@ -1,15 +1,8 @@ -import { afterAll, beforeAll, describe, expect, test } from "bun:test"; +import { afterAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(1); const timeline = await getTestStatuses(10, users[0]); diff --git a/server/api/api/v1/mutes/index.test.ts b/server/api/api/v1/mutes/index.test.ts index 68c2f3f3..1e781924 100644 --- a/server/api/api/v1/mutes/index.test.ts +++ b/server/api/api/v1/mutes/index.test.ts @@ -1,14 +1,8 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(3); afterAll(async () => { diff --git a/server/api/api/v1/notifications/:id/dismiss.test.ts b/server/api/api/v1/notifications/:id/dismiss.test.ts index be203108..3409a3e5 100644 --- a/server/api/api/v1/notifications/:id/dismiss.test.ts +++ b/server/api/api/v1/notifications/:id/dismiss.test.ts @@ -1,15 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Notification as APINotification } from "~types/mastodon/notification"; import { meta } from "./dismiss"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(2); let notifications: APINotification[] = []; diff --git a/server/api/api/v1/notifications/:id/index.test.ts b/server/api/api/v1/notifications/:id/index.test.ts index d284f782..8333a993 100644 --- a/server/api/api/v1/notifications/:id/index.test.ts +++ b/server/api/api/v1/notifications/:id/index.test.ts @@ -1,15 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Notification as APINotification } from "~types/mastodon/notification"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(2); let notifications: APINotification[] = []; diff --git a/server/api/api/v1/notifications/clear/index.test.ts b/server/api/api/v1/notifications/clear/index.test.ts index 1e1561c4..54957475 100644 --- a/server/api/api/v1/notifications/clear/index.test.ts +++ b/server/api/api/v1/notifications/clear/index.test.ts @@ -1,15 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Notification as APINotification } from "~types/mastodon/notification"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(2); let notifications: APINotification[] = []; diff --git a/server/api/api/v1/notifications/destroy_multiple/index.test.ts b/server/api/api/v1/notifications/destroy_multiple/index.test.ts index a6fe96e3..600a834c 100644 --- a/server/api/api/v1/notifications/destroy_multiple/index.test.ts +++ b/server/api/api/v1/notifications/destroy_multiple/index.test.ts @@ -1,16 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import type { Notification as APINotification } from "~types/mastodon/notification"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(2); const statuses = await getTestStatuses(40, users[0]); let notifications: APINotification[] = []; diff --git a/server/api/api/v1/notifications/index.test.ts b/server/api/api/v1/notifications/index.test.ts index c4545834..4525713e 100644 --- a/server/api/api/v1/notifications/index.test.ts +++ b/server/api/api/v1/notifications/index.test.ts @@ -1,16 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import type { Notification as APINotification } from "~types/mastodon/notification"; import { meta } from "./index"; -await deleteOldTestUsers(); - const getFormData = (object: Record) => Object.keys(object).reduce((formData, key) => { formData.append(key, String(object[key])); diff --git a/server/api/api/v1/sso/:id/index.test.ts b/server/api/api/v1/sso/:id/index.test.ts index 5938d249..8c7b652f 100644 --- a/server/api/api/v1/sso/:id/index.test.ts +++ b/server/api/api/v1/sso/:id/index.test.ts @@ -1,14 +1,8 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "~packages/config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { deleteUsers, tokens } = await getTestUsers(1); afterAll(async () => { diff --git a/server/api/api/v1/sso/index.test.ts b/server/api/api/v1/sso/index.test.ts index 2b44088e..1e350f2e 100644 --- a/server/api/api/v1/sso/index.test.ts +++ b/server/api/api/v1/sso/index.test.ts @@ -1,14 +1,8 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "~packages/config-manager"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { deleteUsers, tokens } = await getTestUsers(1); afterAll(async () => { diff --git a/server/api/api/v1/statuses/:id/favourited_by.test.ts b/server/api/api/v1/statuses/:id/favourited_by.test.ts index 34ee0716..6ba826a0 100644 --- a/server/api/api/v1/statuses/:id/favourited_by.test.ts +++ b/server/api/api/v1/statuses/:id/favourited_by.test.ts @@ -1,16 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import type { Account as APIAccount } from "~types/mastodon/account"; import { meta } from "./favourited_by"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); const timeline = (await getTestStatuses(40, users[0])).toReversed(); diff --git a/server/api/api/v1/statuses/:id/reblogged_by.test.ts b/server/api/api/v1/statuses/:id/reblogged_by.test.ts index 29d79c2e..cc054638 100644 --- a/server/api/api/v1/statuses/:id/reblogged_by.test.ts +++ b/server/api/api/v1/statuses/:id/reblogged_by.test.ts @@ -1,16 +1,9 @@ import { afterAll, beforeAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import type { Account as APIAccount } from "~types/mastodon/account"; import { meta } from "./reblogged_by"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); const timeline = (await getTestStatuses(40, users[0])).toReversed(); diff --git a/server/api/api/v1/statuses/index.test.ts b/server/api/api/v1/statuses/index.test.ts index f3f50a8f..c9e06618 100644 --- a/server/api/api/v1/statuses/index.test.ts +++ b/server/api/api/v1/statuses/index.test.ts @@ -3,16 +3,10 @@ import { config } from "config-manager"; import { eq } from "drizzle-orm"; import { db } from "~drizzle/db"; import { Emojis } from "~drizzle/schema"; -import { - deleteOldTestUsers, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestUsers, sendTestRequest } from "~tests/utils"; import type { Status as APIStatus } from "~types/mastodon/status"; import { meta } from "./index"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); afterAll(async () => { diff --git a/server/api/api/v1/timelines/home.test.ts b/server/api/api/v1/timelines/home.test.ts index b38127e7..9f447fbb 100644 --- a/server/api/api/v1/timelines/home.test.ts +++ b/server/api/api/v1/timelines/home.test.ts @@ -1,16 +1,9 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import type { Status as APIStatus } from "~types/mastodon/status"; import { meta } from "./home"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); const timeline = (await getTestStatuses(40, users[0])).toReversed(); diff --git a/server/api/api/v1/timelines/public.test.ts b/server/api/api/v1/timelines/public.test.ts index fe5c9eda..792a3fac 100644 --- a/server/api/api/v1/timelines/public.test.ts +++ b/server/api/api/v1/timelines/public.test.ts @@ -1,16 +1,9 @@ import { afterAll, describe, expect, test } from "bun:test"; import { config } from "config-manager"; -import { - deleteOldTestUsers, - getTestStatuses, - getTestUsers, - sendTestRequest, -} from "~tests/utils"; +import { getTestStatuses, getTestUsers, sendTestRequest } from "~tests/utils"; import type { Status as APIStatus } from "~types/mastodon/status"; import { meta } from "./public"; -await deleteOldTestUsers(); - const { users, tokens, deleteUsers } = await getTestUsers(5); const timeline = (await getTestStatuses(40, users[0])).toReversed(); diff --git a/tests/setup.ts b/tests/setup.ts new file mode 100644 index 00000000..b29f7714 --- /dev/null +++ b/tests/setup.ts @@ -0,0 +1,5 @@ +import { setupDatabase } from "~drizzle/db"; +import { deleteOldTestUsers } from "./utils"; + +await setupDatabase(); +await deleteOldTestUsers();