mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
I did a fucked up polymorphism
This commit is contained in:
parent
f893a81464
commit
4f46a69131
2 changed files with 6 additions and 15 deletions
|
|
@ -13,10 +13,7 @@ import { createTestDB } from '@/test.ts';
|
||||||
import cashuRoute from './cashu.ts';
|
import cashuRoute from './cashu.ts';
|
||||||
import { walletSchema } from '@/schema.ts';
|
import { walletSchema } from '@/schema.ts';
|
||||||
|
|
||||||
Deno.test('PUT /wallet must be successful', {
|
Deno.test('PUT /wallet must be successful', async () => {
|
||||||
sanitizeOps: false,
|
|
||||||
sanitizeResources: false,
|
|
||||||
}, async () => {
|
|
||||||
await using test = await createTestRoute();
|
await using test = await createTestRoute();
|
||||||
|
|
||||||
const { route, signer, sk, relay } = test;
|
const { route, signer, sk, relay } = test;
|
||||||
|
|
@ -101,10 +98,7 @@ Deno.test('PUT /wallet must NOT be successful: wrong request body/schema', async
|
||||||
assertObjectMatch(body, { error: 'Bad schema' });
|
assertObjectMatch(body, { error: 'Bad schema' });
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test('PUT /wallet must NOT be successful: wallet already exists', {
|
Deno.test('PUT /wallet must NOT be successful: wallet already exists', async () => {
|
||||||
sanitizeOps: false,
|
|
||||||
sanitizeResources: false,
|
|
||||||
}, async () => {
|
|
||||||
await using test = await createTestRoute();
|
await using test = await createTestRoute();
|
||||||
const { route, sk, relay } = test;
|
const { route, sk, relay } = test;
|
||||||
|
|
||||||
|
|
@ -127,10 +121,7 @@ Deno.test('PUT /wallet must NOT be successful: wallet already exists', {
|
||||||
assertEquals(body2, { error: 'You already have a wallet 😏' });
|
assertEquals(body2, { error: 'You already have a wallet 😏' });
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test('GET /wallet must be successful', {
|
Deno.test('GET /wallet must be successful', async () => {
|
||||||
sanitizeOps: false,
|
|
||||||
sanitizeResources: false,
|
|
||||||
}, async () => {
|
|
||||||
await using test = await createTestRoute();
|
await using test = await createTestRoute();
|
||||||
const { route, sk, relay, signer } = test;
|
const { route, sk, relay, signer } = test;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,9 +164,9 @@ export class DittoPgStore extends NPostgres {
|
||||||
opts: { signal?: AbortSignal; timeout?: number } = {},
|
opts: { signal?: AbortSignal; timeout?: number } = {},
|
||||||
): Promise<undefined> {
|
): Promise<undefined> {
|
||||||
try {
|
try {
|
||||||
await this.transaction(async (store, kysely) => {
|
await super.transaction(async (store, kysely) => {
|
||||||
await updateStats({ event, store, kysely });
|
await updateStats({ event, store, kysely: kysely as unknown as Kysely<DittoTables> });
|
||||||
await super.event(event, opts);
|
await store.event(event, opts);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// If the failure is only because of updateStats (which runs first), insert the event anyway.
|
// If the failure is only because of updateStats (which runs first), insert the event anyway.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue