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]);
|
||||
|
||||
await kysely
|
||||
.insertInto('author_stats')
|
||||
.values({
|
||||
.updateTable('author_stats')
|
||||
.set({
|
||||
pubkey: event1.pubkey,
|
||||
nip05_domain: 'gleasonator.dev',
|
||||
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(
|
||||
() => store.event(event),
|
||||
RelayError,
|
||||
// RelayError,
|
||||
'event deleted by user',
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -148,10 +148,16 @@ export class DittoPgStore extends NPostgres {
|
|||
await this.storeEvent(event, { ...opts, timeout: opts.timeout ?? this.opts.timeout });
|
||||
this.fulfill(event); // don't await or catch (should never reject)
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.message === 'Cannot add a deleted event') {
|
||||
throw new RelayError('blocked', 'event deleted by user');
|
||||
} else if (e instanceof Error && e.message === 'Cannot replace an event with an older event') {
|
||||
return;
|
||||
if (e instanceof Error) {
|
||||
switch (e.message) {
|
||||
case 'duplicate key value violates unique constraint "nostr_events_pkey"':
|
||||
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 {
|
||||
throw e;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue