Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Feb 23, 2024
1 parent 0140b3a commit 5d1d4ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/scripts/integration-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ async function main() {
execSync('yarn prebuild:scripts', { stdio: 'inherit' });
execSync('yarn build:esbuild', { stdio: 'inherit' });

const result = execSync('vitest run --config vitest.integration.config.ts', {
execSync('vitest run --config vitest.integration.config.ts', {
stdio: 'inherit',
encoding: 'utf-8'
});
console.log(result.toString());
} catch (err) {
throw new Error(err as any);
} finally {
Expand Down
17 changes: 16 additions & 1 deletion tests/integration/setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import '../globalSetup';

import { vi } from 'vitest';
import { beforeAll, beforeEach, vi } from 'vitest';

import { prisma } from '../../src/lib/settings/prisma';

vi.mock('../../src/lib/util/handleMahojiConfirmation', () => ({
handleMahojiConfirmation: vi.fn()
Expand All @@ -26,3 +28,16 @@ globalClient.fetchUser = async (id: string | bigint) => ({
id: typeof id === 'string' ? id : String(id),
send: async () => {}
});

beforeAll(async () => {
console.log(
await prisma.$queryRawUnsafe(`SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE state = 'idle'
AND pid <> pg_backend_pid();`)
);
});

beforeEach(async () => {
console.log(await prisma.$queryRawUnsafe('SELECT COUNT(*) FROM pg_stat_activity;'));
});

0 comments on commit 5d1d4ad

Please sign in to comment.