clawdie-ai/setup/sanoid.test.ts
Operator & Codex 316a70c86c Honor configured ZFS pool for host DB datasets
Use the shared host DB dataset builder for sanoid selection and host PostgreSQL provisioning so dataset names follow operator-configured ZFS_POOL and ZFS_PREFIX instead of assuming zroot. Also add direct coverage for canonical sanoid dataset selection.

---
Build: pass | Tests: FAIL — Tests  3 failed | 2096 passed (2099)
2026-05-02 08:16:24 +02:00

42 lines
1.3 KiB
TypeScript

import { afterEach, describe, expect, it } from 'vitest';
import { buildHostDbDatasets } from '../src/maintenance-snapshots.js';
import { buildTargetDatasets } from './sanoid.js';
describe('buildTargetDatasets', () => {
const originalPool = process.env.ZFS_POOL;
afterEach(() => {
if (originalPool === undefined) {
delete process.env.ZFS_POOL;
return;
}
process.env.ZFS_POOL = originalPool;
});
it('selects only the canonical host DB datasets for the configured pool', () => {
process.env.ZFS_POOL = 'tank';
const { data, wal } = buildHostDbDatasets();
const targets = buildTargetDatasets(
[
{ name: 'zroot/old-prefix/pgdata', mountpoint: '/var/db/postgres/data' },
{ name: 'zroot/old-prefix/pgwal', mountpoint: '/var/db/postgres/wal' },
{ name: data, mountpoint: '/var/db/postgres/data' },
{ name: wal, mountpoint: '/var/db/postgres/wal' },
],
{},
);
expect(targets).toContainEqual({ dataset: data, template: 'critical_data' });
expect(targets).toContainEqual({ dataset: wal, template: 'critical_data' });
expect(targets).not.toContainEqual({
dataset: 'zroot/old-prefix/pgdata',
template: 'critical_data',
});
expect(targets).not.toContainEqual({
dataset: 'zroot/old-prefix/pgwal',
template: 'critical_data',
});
});
});