feat(api): complete NaxOS management daemon, GitOps engine, ZFS controller, and test suite
CI & Test NaxOS Management API / test (push) Failing after 2m49s

This commit is contained in:
Lukas Holzner
2026-09-03 23:56:02 +02:00
parent 2f42656c2d
commit a283feedbd
27 changed files with 4882 additions and 2 deletions
+51
View File
@@ -0,0 +1,51 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { GitOpsService } from '../src/services/gitops.service.js';
import os from 'os';
import path from 'path';
import fs from 'fs/promises';
describe('GitOpsService', () => {
let gitops: GitOpsService;
let testRepoDir: string;
beforeEach(async () => {
testRepoDir = path.join(os.tmpdir(), `naxos-gitops-test-${Date.now()}-${Math.random().toString(36).slice(2)}`);
gitops = new GitOpsService(testRepoDir);
await gitops.init();
});
afterEach(async () => {
try {
await fs.rm(testRepoDir, { recursive: true, force: true });
} catch {}
});
it('should initialize and produce valid GitOps status', async () => {
const status = await gitops.getStatus();
expect(status.enabled).toBe(true);
expect(status.branch).toBe('main');
expect(status.lastCommitSha).toBeDefined();
});
it('should translate declarative configuration into valid NixOS module code', async () => {
const nixCode = await gitops.renderNixOSModule();
expect(nixCode).toContain('services.naxos.storage');
expect(nixCode).toContain('services.naxos.shares.samba');
expect(nixCode).toContain('importExistingPools');
expect(nixCode).toContain('tank');
});
it('should create commits on state changes', async () => {
const res = await gitops.updateConfig(
{
core: { hostname: 'naxos-test', timezone: 'UTC' },
},
'feat(test): updated hostname'
);
expect(res.commitSha).toBeDefined();
expect(res.commitSha.length).toBeGreaterThan(10);
const commits = await gitops.getCommits(5);
expect(commits[0].message).toBe('feat(test): updated hostname');
});
});