mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
refactor: ✅ Only delete old test users once at preload
This commit is contained in:
parent
f5a0f52b93
commit
5b658984a5
|
|
@ -1,2 +1,5 @@
|
|||
[install.scopes]
|
||||
"@jsr" = "https://npm.jsr.io"
|
||||
|
||||
[test]
|
||||
preload = ["./tests/setup.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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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[] = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -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[] = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -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[] = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -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[] = [];
|
||||
|
|
|
|||
|
|
@ -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<string, string | number | boolean>) =>
|
||||
Object.keys(object).reduce((formData, key) => {
|
||||
formData.append(key, String(object[key]));
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
5
tests/setup.ts
Normal file
5
tests/setup.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { setupDatabase } from "~drizzle/db";
|
||||
import { deleteOldTestUsers } from "./utils";
|
||||
|
||||
await setupDatabase();
|
||||
await deleteOldTestUsers();
|
||||
Loading…
Reference in a new issue