mirror of
https://github.com/db9979/tiefenkontakt.git
synced 2026-12-05 12:24:12 +01:00
- Escorts: bridge lookouts (periscope feather, snorkel, surfaced boats, torpedo tracks), spoken sighting reports, 3D bridge station with binoculars and own foredeck, lookout hit inset - 3D sea split into models/shaders: multi-wave ocean with whitecaps, clouds, sun and moon, detailed ships with smoke and turning radar - Radar room rebuilt as phosphor PPI with range scales, ESM rose and radar status; NATO symbols on plot, mission charts and replay - Sortable and filterable contact list, leaderboard and alert log; smoothed list bearings; clear convoy progress bar - Ops: backups, metrics, structured logs, CI, Elo ratings, private matches, corvette and coastal sub, network load test - Mail: configurable SMTP (Gmail/iCloud), signal-style HTML mails with inline sonar header, mail test command - Fixes: spoofable client IP behind proxy, phone layout and lost taps, stacked debriefs, station 5 rejected by server - Raspberry Pi deploy script and .env.example
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { mkdtempSync } from 'node:fs';
|
|
import { DatabaseSync } from 'node:sqlite';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { Backups } from '../src/backup.js';
|
|
|
|
describe('database backups', () => {
|
|
it('writes a readable copy and keeps only the newest N', () => {
|
|
const dir = mkdtempSync(join(tmpdir(), 'tk-bak-'));
|
|
const db = new DatabaseSync(join(dir, 'live.db'));
|
|
db.exec('CREATE TABLE t (v TEXT); INSERT INTO t VALUES (\'Seewolf\')');
|
|
const b = new Backups(db, join(dir, 'bak'), 2, 24);
|
|
for (let i = 0; i < 4; i++) b.run(new Date(Date.UTC(2026, 10, 20 + i, 3, 0, 0)));
|
|
const files = b.list();
|
|
expect(files.map((f) => f.file)).toEqual(['tiefenkontakt-20261123-030000.db', 'tiefenkontakt-20261122-030000.db']);
|
|
const copy = new DatabaseSync(join(dir, 'bak', files[0]!.file));
|
|
expect(copy.prepare('SELECT v FROM t').get()).toEqual({ v: 'Seewolf' });
|
|
});
|
|
|
|
it('does nothing without BACKUP_DIR', () => {
|
|
const b = new Backups(new DatabaseSync(':memory:'), undefined);
|
|
expect(b.enabled).toBe(false);
|
|
expect(b.run()).toBeUndefined();
|
|
});
|
|
});
|