Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

test(logs): reduced log spam in test (#594)

Corentin Thomasset2c75eec86261
diff --git a/apps/papra-server/package.json b/apps/papra-server/package.json
index 9c5f3db1..0c28cbf9 100644
--- a/apps/papra-server/package.json
+++ b/apps/papra-server/package.json
@@ -45,8 +45,8 @@
"@cadence-mq/driver-memory": "^0.2.0",
"@corentinth/chisels": "catalog:",
"@corentinth/friendly-ids": "^0.0.1",
- "@crowlog/async-context-plugin": "^1.2.1",
- "@crowlog/logger": "^1.2.1",
+ "@crowlog/async-context-plugin": "^2.0.0",
+ "@crowlog/logger": "^2.0.0",
"@hono/node-server": "^1.14.4",
"@libsql/client": "^0.14.0",
"@owlrelay/api-sdk": "^0.0.2",
@@ -81,7 +81,7 @@
},
"devDependencies": {
"@antfu/eslint-config": "catalog:",
- "@crowlog/pretty": "^1.2.1",
+ "@crowlog/pretty": "^2.0.0",
"@testcontainers/azurite": "^11.5.1",
"@testcontainers/localstack": "^11.5.1",
"@total-typescript/ts-reset": "^0.6.1",
diff --git a/apps/papra-server/src/migrations/migrations.registry.test.ts b/apps/papra-server/src/migrations/migrations.registry.test.ts
index 2eceb211..8e5a6fc3 100644
--- a/apps/papra-server/src/migrations/migrations.registry.test.ts
+++ b/apps/papra-server/src/migrations/migrations.registry.test.ts
@@ -1,4 +1,5 @@
import type { Migration } from './migrations.types';
+import { createNoopLogger } from '@crowlog/logger';
import { sql } from 'drizzle-orm';
import { describe, expect, test } from 'vitest';
import { setupDatabase } from '../modules/app/database/database';
@@ -26,7 +27,7 @@ describe('migrations registry', () => {
const { db } = setupDatabase({ url: ':memory:' });
// This will throw if any migration is not able to be applied
- await runMigrations({ db, migrations });
+ await runMigrations({ db, migrations, logger: createNoopLogger() });
// check foreign keys are enabled
const { rows } = await db.run(sql`pragma foreign_keys;`);
@@ -39,7 +40,7 @@ describe('migrations registry', () => {
for (const migrationCombination of migrationCombinations) {
const { db } = setupDatabase({ url: ':memory:' });
- await runMigrations({ db, migrations: migrationCombination });
+ await runMigrations({ db, migrations: migrationCombination, logger: createNoopLogger() });
}
});
@@ -51,9 +52,9 @@ describe('migrations registry', () => {
const { db } = setupDatabase({ url: ':memory:' });
const previousMigration = migrationCombinations[index - 1] ?? [] as Migration[];
- await runMigrations({ db, migrations: previousMigration });
+ await runMigrations({ db, migrations: previousMigration, logger: createNoopLogger() });
const previousDbState = await serializeSchema({ db });
- await runMigrations({ db, migrations: migrationCombination });
+ await runMigrations({ db, migrations: migrationCombination, logger: createNoopLogger() });
await rollbackLastAppliedMigration({ db });
const currentDbState = await serializeSchema({ db });
@@ -65,7 +66,7 @@ describe('migrations registry', () => {
test('regression test of the database state after running migrations, update the snapshot when the database state changes', async () => {
const { db } = setupDatabase({ url: ':memory:' });
- await runMigrations({ db, migrations });
+ await runMigrations({ db, migrations, logger: createNoopLogger() });
expect(await serializeSchema({ db })).toMatchInlineSnapshot(`
"CREATE UNIQUE INDEX "api_keys_key_hash_unique" ON "api_keys" ("key_hash");
@@ -131,12 +132,12 @@ describe('migrations registry', () => {
test('if for some reasons we drop the migrations table, we can reapply all migrations', async () => {
const { db } = setupDatabase({ url: ':memory:' });
- await runMigrations({ db, migrations });
+ await runMigrations({ db, migrations, logger: createNoopLogger() });
const dbState = await serializeSchema({ db });
await db.run(sql`DROP TABLE migrations`);
- await runMigrations({ db, migrations });
+ await runMigrations({ db, migrations, logger: createNoopLogger() });
expect(await serializeSchema({ db })).to.eq(dbState);
});
diff --git a/apps/papra-server/src/migrations/migrations.usecases.test.ts b/apps/papra-server/src/migrations/migrations.usecases.test.ts
index 25a39d08..df56650e 100644
--- a/apps/papra-server/src/migrations/migrations.usecases.test.ts
+++ b/apps/papra-server/src/migrations/migrations.usecases.test.ts
@@ -1,4 +1,5 @@
import type { Migration } from './migrations.types';
+import { createNoopLogger } from '@crowlog/logger';
import { sql } from 'drizzle-orm';
import { describe, expect, test } from 'vitest';
import { setupDatabase } from '../modules/app/database/database';
@@ -50,7 +51,7 @@ describe('migrations usecases', () => {
const migrations = [createTableUserMigration, createTableOrganizationMigration];
- await runMigrations({ db, migrations });
+ await runMigrations({ db, migrations, logger: createNoopLogger() });
const migrationsInDb = await db.select().from(migrationsTable);
@@ -61,7 +62,7 @@ describe('migrations usecases', () => {
migrations.push(createTableDocumentMigration);
- await runMigrations({ db, migrations });
+ await runMigrations({ db, migrations, logger: createNoopLogger() });
const migrationsInDb2 = await db.select().from(migrationsTable);
@@ -92,7 +93,7 @@ describe('migrations usecases', () => {
const migrations = [createTableUserMigration, createTableDocumentMigration];
- await runMigrations({ db, migrations });
+ await runMigrations({ db, migrations, logger: createNoopLogger() });
const initialMigrations = await db.select().from(migrationsTable);
@@ -131,7 +132,7 @@ describe('migrations usecases', () => {
test('when the last migration in the database does not exist in the migrations list, an error is thrown', async () => {
const { db } = setupDatabase({ url: ':memory:' });
- await runMigrations({ db, migrations: [createTableUserMigration] });
+ await runMigrations({ db, migrations: [createTableUserMigration], logger: createNoopLogger() });
await expect(
rollbackLastAppliedMigration({ db, migrations: [] }),
diff --git a/apps/papra-server/src/modules/app/database/database.test-utils.ts b/apps/papra-server/src/modules/app/database/database.test-utils.ts
index 6f964ba3..5d81398e 100644
--- a/apps/papra-server/src/modules/app/database/database.test-utils.ts
+++ b/apps/papra-server/src/modules/app/database/database.test-utils.ts
@@ -1,5 +1,5 @@
import type { Database } from './database.types';
-import { createInMemoryLoggerTransport, createLogger } from '@crowlog/logger';
+import { createNoopLogger } from '@crowlog/logger';
import { sql } from 'drizzle-orm';
import { runMigrations } from '../../../migrations/migrations.usecases';
import { apiKeyOrganizationsTable, apiKeysTable } from '../../api-keys/api-keys.tables';
@@ -21,7 +21,7 @@ async function createInMemoryDatabase(seedOptions: Omit<Parameters<typeof seedDa
await runMigrations({
db,
// In memory logger to avoid polluting the console with migrations logs
- logger: createLogger({ transports: [createInMemoryLoggerTransport()], namespace: 'migrations' }),
+ logger: createNoopLogger(),
});
await seedDatabase({ db, ...seedOptions });
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 12050077..e9d78e68 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -266,11 +266,11 @@ importers:
specifier: ^0.0.1
version: 0.0.1
'@crowlog/async-context-plugin':
- specifier: ^1.2.1
- version: 1.2.1
+ specifier: ^2.0.0
+ version: 2.0.0
'@crowlog/logger':
- specifier: ^1.2.1
- version: 1.2.1
+ specifier: ^2.0.0
+ version: 2.0.0
'@hono/node-server':
specifier: ^1.14.4
version: 1.14.4([email protected])
@@ -369,8 +369,8 @@ importers:
specifier: 'catalog:'
'@crowlog/pretty':
- specifier: ^1.2.1
- version: 1.2.1
+ specifier: ^2.0.0
+ version: 2.0.0
'@testcontainers/azurite':
specifier: ^11.5.1
version: 11.5.1
@@ -970,6 +970,10 @@ packages:
resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==}
engines: {node: '>=6.9.0'}
+ '@babel/[email protected]':
+ resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==}
+ engines: {node: '>=6.9.0'}
+
resolution: {integrity: sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==}
engines: {node: '>=6.9.0'}
@@ -993,6 +997,11 @@ packages:
engines: {node: '>=6.0.0'}
hasBin: true
+ '@babel/[email protected]':
+ resolution: {integrity: sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==}
+ engines: {node: '>=6.0.0'}
+ hasBin: true
+
resolution: {integrity: sha512-y8YTNIeKoyhGd9O0Jiyzyyqk8gdjnumGTQPsz0xOZOQ2RmkVJeZ1vmmfIvFEKqucBG6axJGBZDE/7iI5suUI/w==}
engines: {node: '>=6.9.0'}
@@ -1023,6 +1032,10 @@ packages:
resolution: {integrity: sha512-bkFqkLhh3pMBUQQkpVgWDWq/lqzc2678eUyDlTBhRqhCHFguYYGM0Efga7tYk4TogG/3x0EEl66/OQ+WGbWB/Q==}
engines: {node: '>=6.9.0'}
+ '@babel/[email protected]':
+ resolution: {integrity: sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==}
+ engines: {node: '>=6.9.0'}
+
'@balena/[email protected]':
resolution: {integrity: sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==}
@@ -1144,16 +1157,16 @@ packages:
peerDependencies:
solid-js: ^1.8
- '@crowlog/[email protected]':
- resolution: {integrity: sha512-pvr1zrEu2wqqdx3H/z/wNtULdoe3ZO3eNElphg7hwuQUHMXtXiX2qzy1x9EUG8FbiJLEdU35aDIq90j5ks+pFQ==}
+ '@crowlog/[email protected]':
+ resolution: {integrity: sha512-nlzv+dXfWxuY2/O05m05YT/1e5u/x/EKF1HnHdNJVDUI7OUs4ZrNF1jsKP9GnNoApaXNnYiPrDBlYcH80DkDPw==}
engines: {node: '>=22.0.0'}
- '@crowlog/[email protected]':
- resolution: {integrity: sha512-I5q/pASank5Aj9z1r1uIDcDGQ9XipP1OqZXrE4tt+DU+Ty0WjfKal5s+9BS2+dfroOOffMgdQgzLxL/2hkDGpQ==}
+ '@crowlog/[email protected]':
+ resolution: {integrity: sha512-TNbi6SutY8gvwvE6YvJIxOxa6Rrj6u8iieawwF+KzSbxxBAgPQ7wtGI5Hmf4LSs6dJNElx441Cw4vQyMHFlq5w==}
engines: {node: '>=22.0.0'}
- '@crowlog/[email protected]':
- resolution: {integrity: sha512-N/V3bYpq6XfBklBxFomutm3zHNSq8dp57JGiXK87Pi9tGsvUTS4daoKETEEJEA2R3OgWdWLYfeZO/cz4qeU8Ng==}
+ '@crowlog/[email protected]':
+ resolution: {integrity: sha512-pNn5cOnTrR4ht2GFTRmgpMDdPnLMTc/MN/subAWVVzQmpbT4Pn3I5nsORAMHIzROA0PGSUFd9TKidxEuPhP32w==}
engines: {node: '>=22.0.0'}
hasBin: true
@@ -5872,6 +5885,9 @@ packages:
resolution: {integrity: sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==}
+ resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
+
resolution: {integrity: sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==}
@@ -7193,11 +7209,11 @@ packages:
resolution: {integrity: sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==}
engines: {node: '>=14.0.0'}
- resolution: {integrity: sha512-NaQa1W76W2aCGjXybvnMYzGSM4x8fvG2AN/pla7qxcg0ZHbooOPhA8kctmOZUDfZyhDL27OGNbwAeig8P4p1vg==}
+ resolution: {integrity: sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==}
- resolution: {integrity: sha512-aRGIbCIF3teodtUFAYSdQONVmDRy21REM3o6JnqWn5ZkQBJJ4gHxhw6OfwQ+WkSAi3ASamrS4N4nyazWx6uTYg==}
+ resolution: {integrity: sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==}
hasBin: true
@@ -7227,8 +7243,8 @@ packages:
resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
- resolution: {integrity: sha512-IUWnUK7ADYR5Sl1fZlO1INDUhVhatWl7BtJWsIhwJ0UAK7ilzzIa8uIqOO/aYVWHZPJkKbEL+362wrzoeRF7bw==}
+ resolution: {integrity: sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==}
engines: {node: '>=18'}
@@ -8894,6 +8910,8 @@ snapshots:
'@babel/[email protected]': {}
+ '@babel/[email protected]': {}
+
'@babel/[email protected]': {}
@@ -8913,6 +8931,10 @@ snapshots:
dependencies:
'@babel/types': 7.28.4
+ '@babel/[email protected]':
+ dependencies:
+ '@babel/types': 7.28.5
+
dependencies:
'@babel/core': 7.28.4
@@ -8962,6 +8984,11 @@ snapshots:
'@babel/helper-string-parser': 7.27.1
'@babel/helper-validator-identifier': 7.27.1
+ '@babel/[email protected]':
+ dependencies:
+ '@babel/helper-string-parser': 7.27.1
+ '@babel/helper-validator-identifier': 7.28.5
+
'@balena/[email protected]': {}
'@bcoe/[email protected]': {}
@@ -9189,11 +9216,11 @@ snapshots:
'@floating-ui/dom': 1.6.13
solid-js: 1.9.9
- '@crowlog/[email protected]': {}
+ '@crowlog/[email protected]': {}
- '@crowlog/[email protected]': {}
+ '@crowlog/[email protected]': {}
- '@crowlog/[email protected]':
+ '@crowlog/[email protected]':
dependencies:
picocolors: 1.1.1
@@ -11797,7 +11824,7 @@ snapshots:
dependencies:
- '@babel/parser': 7.28.4
+ '@babel/parser': 7.28.5
'@vue/shared': 3.5.13
entities: 4.5.0
estree-walker: 2.0.2
@@ -11810,13 +11837,13 @@ snapshots:
dependencies:
- '@babel/parser': 7.28.4
+ '@babel/parser': 7.28.5
'@vue/compiler-core': 3.5.13
'@vue/compiler-dom': 3.5.13
'@vue/compiler-ssr': 3.5.13
'@vue/shared': 3.5.13
estree-walker: 2.0.2
- magic-string: 0.30.19
+ magic-string: 0.30.21
postcss: 8.5.6
source-map-js: 1.2.1
@@ -14155,6 +14182,10 @@ snapshots:
dependencies:
'@jridgewell/sourcemap-codec': 1.5.5
+ dependencies:
+ '@jridgewell/sourcemap-codec': 1.5.5
+
dependencies:
'@babel/parser': 7.28.0
@@ -16032,12 +16063,12 @@ snapshots:
optional: true
dependencies:
- tldts-core: 6.1.84
+ tldts-core: 6.1.86
optional: true
@@ -16058,12 +16089,12 @@ snapshots:
dependencies:
- tldts: 6.1.84
+ tldts: 6.1.86
optional: true
dependencies:
punycode: 2.3.1
optional: true
@@ -16662,7 +16693,7 @@ snapshots:
dependencies:
- tr46: 5.1.0
+ tr46: 5.1.1
webidl-conversions: 7.0.0
optional: true