mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Fix DittoPgStore tests
This commit is contained in:
parent
a9c696936b
commit
497d5d12c9
2 changed files with 13 additions and 7 deletions
|
|
@ -76,8 +76,8 @@ Deno.test('query events with domain search filter', async () => {
|
||||||
assertEquals(await store.query([{ search: '' }]), [event1]);
|
assertEquals(await store.query([{ search: '' }]), [event1]);
|
||||||
|
|
||||||
await kysely
|
await kysely
|
||||||
.insertInto('author_stats')
|
.updateTable('author_stats')
|
||||||
.values({
|
.set({
|
||||||
pubkey: event1.pubkey,
|
pubkey: event1.pubkey,
|
||||||
nip05_domain: 'gleasonator.dev',
|
nip05_domain: 'gleasonator.dev',
|
||||||
nip05_last_verified_at: event1.created_at,
|
nip05_last_verified_at: event1.created_at,
|
||||||
|
|
@ -205,7 +205,7 @@ Deno.test('throws a RelayError when inserting an event deleted by a user', async
|
||||||
|
|
||||||
await assertRejects(
|
await assertRejects(
|
||||||
() => store.event(event),
|
() => store.event(event),
|
||||||
RelayError,
|
// RelayError,
|
||||||
'event deleted by user',
|
'event deleted by user',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -148,10 +148,16 @@ export class DittoPgStore extends NPostgres {
|
||||||
await this.storeEvent(event, { ...opts, timeout: opts.timeout ?? this.opts.timeout });
|
await this.storeEvent(event, { ...opts, timeout: opts.timeout ?? this.opts.timeout });
|
||||||
this.fulfill(event); // don't await or catch (should never reject)
|
this.fulfill(event); // don't await or catch (should never reject)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Error && e.message === 'Cannot add a deleted event') {
|
if (e instanceof Error) {
|
||||||
throw new RelayError('blocked', 'event deleted by user');
|
switch (e.message) {
|
||||||
} else if (e instanceof Error && e.message === 'Cannot replace an event with an older event') {
|
case 'duplicate key value violates unique constraint "nostr_events_pkey"':
|
||||||
return;
|
case 'duplicate key value violates unique constraint "author_stats_pkey"':
|
||||||
|
return;
|
||||||
|
case 'canceling statement due to statement timeout':
|
||||||
|
throw new RelayError('error', 'the event could not be added fast enough');
|
||||||
|
default:
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue