Publish curated ForgeFlow source from 2ed1787c0b52
This commit is contained in:
commit
f60b269686
254 files changed
+46204
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs/promises';
|
||||
import auditModule from '../src/main/audit-service.cjs';
|
||||
|
||||
const { AuditService } = auditModule;
|
||||
|
||||
test('audit service appends ordered records and exports CSV', async (t) => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'forgeflow-audit-'));
|
||||
t.after(() => fs.rm(root, { recursive: true, force: true }));
|
||||
const audit = new AuditService({ userDataPath: root, appInfo: { version: 'test' } });
|
||||
await Promise.all([
|
||||
audit.append('deployment.requested', { repository: 'owner/app', sha: 'a'.repeat(40), note: 'Release, wave 1' }),
|
||||
audit.append('deployment.completed', { repository: 'owner/app', result: 'success' })
|
||||
]);
|
||||
const entries = await audit.list();
|
||||
assert.equal(entries.length, 2);
|
||||
assert.equal(entries[0].event, 'deployment.completed');
|
||||
const destination = path.join(root, 'audit.csv');
|
||||
const result = await audit.exportTo(destination, 'csv');
|
||||
assert.equal(result.count, 2);
|
||||
assert.match(await fs.readFile(destination, 'utf8'), /"Release, wave 1"/);
|
||||
});
|
||||
Reference in new issue
Block a user