before functional changes by codex

This commit is contained in:
znetsixe
2026-02-19 17:37:21 +01:00
parent f979b1ae2b
commit 9e0e3e3859
18 changed files with 747 additions and 1 deletions

View File

@@ -0,0 +1,48 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const EXAMPLES_DIR = path.resolve(__dirname, '../../examples');
function readFlow(file) {
const full = path.join(EXAMPLES_DIR, file);
const parsed = JSON.parse(fs.readFileSync(full, 'utf8'));
assert.equal(Array.isArray(parsed), true);
return parsed;
}
function nodesByType(flow, type) {
return flow.filter((n) => n && n.type === type);
}
function injectByTopic(flow, topic) {
return flow.filter((n) => n && n.type === 'inject' && n.topic === topic);
}
test('examples package contains required files', () => {
for (const name of ['README.md', 'basic.flow.json', 'integration.flow.json', 'edge.flow.json']) {
assert.equal(fs.existsSync(path.join(EXAMPLES_DIR, name)), true, `${name} missing`);
}
});
test('basic flow has measurement node and baseline injects', () => {
const flow = readFlow('basic.flow.json');
assert.equal(nodesByType(flow, 'measurement').length >= 1, true);
assert.equal(injectByTopic(flow, 'measurement').length >= 1, true);
assert.equal(injectByTopic(flow, 'calibrate').length >= 1, true);
});
test('integration flow has two measurement nodes and registerChild example', () => {
const flow = readFlow('integration.flow.json');
assert.equal(nodesByType(flow, 'measurement').length >= 2, true);
assert.equal(injectByTopic(flow, 'registerChild').length >= 1, true);
assert.equal(injectByTopic(flow, 'measurement').length >= 1, true);
});
test('edge flow contains edge-driving injects', () => {
const flow = readFlow('edge.flow.json');
assert.equal(injectByTopic(flow, 'measurement').length >= 1, true);
assert.equal(injectByTopic(flow, 'outlierDetection').length >= 1, true);
assert.equal(injectByTopic(flow, 'doesNotExist').length >= 1, true);
});