before functional changes by codex
This commit is contained in:
48
test/integration/examples-flows.integration.test.js
Normal file
48
test/integration/examples-flows.integration.test.js
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user