master-zapier-plan-draft/packages/verae-fleet/test/classify.test.js
George Lambert 6fbc808bb1
Some checks are pending
offline / test (push) Waiting to run
Color fleet monitor rows: green operational, yellow degraded, red down
Paused or unhealthy replicas mark the service degraded even if the
tree-node floor is still met. Unmanaged NATS with no process is down.
2026-09-11 13:15:52 -04:00

36 lines
1.1 KiB
JavaScript

import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { classifyService } from '../src/classify.js';
describe('classifyService', () => {
it('operational when available meets min and none paused', () => {
assert.equal(
classifyService({ min: 3, available: 3, running: 3, paused: 0, instances: [{ pid: 1, healthy: true }] }),
'operational',
);
});
it('degraded when a replica is paused even if floor is still met', () => {
assert.equal(
classifyService({
min: 3,
available: 3,
running: 4,
paused: 1,
instances: [
{ pid: 1, paused: true, healthy: false },
{ pid: 2, paused: false, healthy: true },
],
}),
'degraded',
);
});
it('not operational when min>0 and nothing available', () => {
assert.equal(classifyService({ min: 1, available: 0, running: 0, paused: 0, instances: [] }), 'down');
});
it('optional idle (min 0, not running) is operational', () => {
assert.equal(classifyService({ min: 0, available: 0, running: 0, paused: 0 }), 'operational');
});
});