mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
test(server): avoid db deadlock on unittest (#10104)
https://github.com/toeverything/AFFiNE/runs/37010719190 
This commit is contained in:
@@ -5,7 +5,7 @@ import { EmailAlreadyUsed, EventBus } from '../../base';
|
||||
import { WorkspaceRole } from '../../core/permission';
|
||||
import { UserModel } from '../../models/user';
|
||||
import { WorkspaceMemberStatus } from '../../models/workspace';
|
||||
import { createTestingModule, type TestingModule } from '../utils';
|
||||
import { createTestingModule, sleep, type TestingModule } from '../utils';
|
||||
|
||||
interface Context {
|
||||
module: TestingModule;
|
||||
@@ -272,6 +272,9 @@ test('should trigger user.deleted event', async t => {
|
||||
t.true(
|
||||
spy.calledOnceWithExactly({ ...user, ownedWorkspaces: ['test-workspace'] })
|
||||
);
|
||||
// await for 'user.deleted' event to be emitted and executed
|
||||
// avoid race condition cause database dead lock
|
||||
await sleep(100);
|
||||
});
|
||||
|
||||
test('should paginate users', async t => {
|
||||
|
||||
@@ -156,8 +156,15 @@ export class TestingApp extends ApplyType<INestApplication>() {
|
||||
.send({
|
||||
query,
|
||||
variables,
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
if (res.status !== 200) {
|
||||
throw new Error(
|
||||
`Failed to execute gql: ${query}, status: ${res.status}, body: ${JSON.stringify(
|
||||
res.body
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
if (res.body.errors?.length) {
|
||||
throw new Error(res.body.errors[0].message);
|
||||
|
||||
Reference in New Issue
Block a user