forked from syntaxbullet/aurorabot
refactor: update database index tests to use DrizzleClient.execute for raw SQL queries.
This commit is contained in:
@@ -1,42 +1,43 @@
|
|||||||
import { expect, test, describe } from "bun:test";
|
import { expect, test, describe } from "bun:test";
|
||||||
import { postgres } from "./DrizzleClient";
|
import { DrizzleClient } from "./DrizzleClient";
|
||||||
|
import { sql } from "drizzle-orm";
|
||||||
|
|
||||||
describe("Database Indexes", () => {
|
describe("Database Indexes", () => {
|
||||||
test("should have indexes on users table", async () => {
|
test("should have indexes on users table", async () => {
|
||||||
const result = await postgres`
|
const result = await DrizzleClient.execute(sql`
|
||||||
SELECT indexname FROM pg_indexes
|
SELECT indexname FROM pg_indexes
|
||||||
WHERE tablename = 'users'
|
WHERE tablename = 'users'
|
||||||
`;
|
`);
|
||||||
const indexNames = (result as unknown as { indexname: string }[]).map(r => r.indexname);
|
const indexNames = result.map(r => r.indexname);
|
||||||
expect(indexNames).toContain("users_balance_idx");
|
expect(indexNames).toContain("users_balance_idx");
|
||||||
expect(indexNames).toContain("users_level_xp_idx");
|
expect(indexNames).toContain("users_level_xp_idx");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should have index on transactions table", async () => {
|
test("should have index on transactions table", async () => {
|
||||||
const result = await postgres`
|
const result = await DrizzleClient.execute(sql`
|
||||||
SELECT indexname FROM pg_indexes
|
SELECT indexname FROM pg_indexes
|
||||||
WHERE tablename = 'transactions'
|
WHERE tablename = 'transactions'
|
||||||
`;
|
`);
|
||||||
const indexNames = (result as unknown as { indexname: string }[]).map(r => r.indexname);
|
const indexNames = result.map(r => r.indexname);
|
||||||
expect(indexNames).toContain("transactions_created_at_idx");
|
expect(indexNames).toContain("transactions_created_at_idx");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should have indexes on moderation_cases table", async () => {
|
test("should have indexes on moderation_cases table", async () => {
|
||||||
const result = await postgres`
|
const result = await DrizzleClient.execute(sql`
|
||||||
SELECT indexname FROM pg_indexes
|
SELECT indexname FROM pg_indexes
|
||||||
WHERE tablename = 'moderation_cases'
|
WHERE tablename = 'moderation_cases'
|
||||||
`;
|
`);
|
||||||
const indexNames = (result as unknown as { indexname: string }[]).map(r => r.indexname);
|
const indexNames = result.map(r => r.indexname);
|
||||||
expect(indexNames).toContain("moderation_cases_user_id_idx");
|
expect(indexNames).toContain("moderation_cases_user_id_idx");
|
||||||
expect(indexNames).toContain("moderation_cases_case_id_idx");
|
expect(indexNames).toContain("moderation_cases_case_id_idx");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should have indexes on user_timers table", async () => {
|
test("should have indexes on user_timers table", async () => {
|
||||||
const result = await postgres`
|
const result = await DrizzleClient.execute(sql`
|
||||||
SELECT indexname FROM pg_indexes
|
SELECT indexname FROM pg_indexes
|
||||||
WHERE tablename = 'user_timers'
|
WHERE tablename = 'user_timers'
|
||||||
`;
|
`);
|
||||||
const indexNames = (result as unknown as { indexname: string }[]).map(r => r.indexname);
|
const indexNames = result.map(r => r.indexname);
|
||||||
expect(indexNames).toContain("user_timers_expires_at_idx");
|
expect(indexNames).toContain("user_timers_expires_at_idx");
|
||||||
expect(indexNames).toContain("user_timers_lookup_idx");
|
expect(indexNames).toContain("user_timers_lookup_idx");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user