Skip to content

Commit

Permalink
Delete all record after all user test
Browse files Browse the repository at this point in the history
 (#11)
  • Loading branch information
shunsei committed Oct 14, 2024
1 parent ac82601 commit d83c2ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
8 changes: 3 additions & 5 deletions backend/test/api/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('GET /users/:userId', () => {
});

afterAll(async () => {
await db.delete(userTable).where(eq(userTable.email, user.email));
await db.delete(userTable);
userFactory.resetSequenceNumber();
});

Expand Down Expand Up @@ -48,9 +48,7 @@ describe('PUT /users/:userId', () => {
});

afterEach(async () => {
for (const user of users) {
await db.delete(userTable).where(eq(userTable.email, user.email));
}
await db.delete(userTable);
});

afterAll(() => {
Expand Down Expand Up @@ -197,7 +195,7 @@ describe('DELETE /users/:userId', () => {
});

afterEach(async () => {
await db.delete(userTable).where(eq(userTable.email, user.email));
await db.delete(userTable);
});

afterAll(() => {
Expand Down
7 changes: 2 additions & 5 deletions backend/test/api/users.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { userTable } from '@/drizzle/schema';
import app from '@/src/index';
import { env } from 'cloudflare:test';
import { count, eq } from 'drizzle-orm';
import { count } from 'drizzle-orm';
import { drizzle } from 'drizzle-orm/d1';
import { userFactory } from '../factories/user';

Expand All @@ -14,10 +14,7 @@ describe('GET /users', () => {
});

afterAll(async () => {
for (const user of users) {
await db.delete(userTable).where(eq(userTable.email, user.email));
}

await db.delete(userTable);
userFactory.resetSequenceNumber();
});

Expand Down

0 comments on commit d83c2ff

Please sign in to comment.