Files
minecraft-atm10-stats/backend/test/db.test.ts
T
lucashahmannandClaude Opus 5.5 e66f89f49e feat: ATM10-Statistikportal
Statistikportal für den All-the-Mods-10-Server (Minecraft 1.21.1, NeoForge 21.1):

- mod/: serverseitige NeoForge-Mod atmstats – Ereignisse, Live-Zähler, Servergesundheit,
  FTB-Dateien; Outbox auf der Festplatte, signierter gzip-Versand per HTTPS mit Backoff
- backend/: Fastify + PostgreSQL – idempotenter Ingest, Projektionen, Parser für SNBT,
  FTB Quests/Teams, world/stats, world/advancements und latest.log; Ranglisten, Snapshots,
  Retention, öffentliche API, SSE-Live-Updates, Admin mit argon2/CSRF, SFTP-Worker
- web/: Next.js-Dashboard – Übersicht, Ranglisten, Spielerprofile, ATM10, Server,
  Datenquellen, Verwaltung
- shared/: Protokoll v1 und API-Typen; tools/: Simulator, Log-Anonymisierer, RCON-Client
- deploy/: Docker Compose hinter Traefik, Backup; docs/: Architektur, Datenquellen, Betrieb

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 09:33:25 +02:00

30 lines
972 B
TypeScript

import { afterAll, describe, expect, it } from 'vitest';
import { loadConfig } from '../src/config.ts';
import { migrate } from '../src/db/migrate.ts';
import { closeTestPool, getTestPool } from './helpers/db.ts';
afterAll(closeTestPool);
describe('database', () => {
it('migrate is idempotent', async () => {
const pool = await getTestPool();
await migrate(pool);
await migrate(pool);
const { rows } = await pool.query(`SELECT to_regclass('public.events') AS t`);
expect(rows[0].t).toBe('events');
});
});
describe('config', () => {
it('loadConfig rejects missing DATABASE_URL', () => {
expect(() => loadConfig({ INGEST_HMAC_SECRET: 'x'.repeat(32) })).toThrow(/DATABASE_URL/);
});
it('loadConfig applies defaults', () => {
const c = loadConfig({ DATABASE_URL: 'postgres://x', INGEST_HMAC_SECRET: 'x'.repeat(32) });
expect(c.PORT).toBe(3001);
expect(c.SFTP_INTERVAL_MIN).toBe(15);
expect(c.sftp).toBeNull();
});
});