69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import { HermesAdapter } from './hermes.adapter';
|
|
const provenance = {
|
|
source: 'snapshot',
|
|
capturedAt: '2020-01-01T00:00:00Z',
|
|
ageSeconds: 100,
|
|
freshness: 'stale',
|
|
liveProcess: 'unknown',
|
|
};
|
|
function adapter(data: unknown) {
|
|
return new HermesAdapter(
|
|
{
|
|
origin: 'http://canina-hermes-inventory:9119',
|
|
token: () => Promise.resolve('test'),
|
|
},
|
|
jest.fn(() =>
|
|
Promise.resolve(new Response(JSON.stringify(data), { status: 200 })),
|
|
) as typeof fetch,
|
|
);
|
|
}
|
|
describe('snapshot provenance boundary', () => {
|
|
it('rejects missing provenance from dedicated inventory origin', async () => {
|
|
await expect(
|
|
adapter({
|
|
ok: true,
|
|
version: '1',
|
|
commit: 'x',
|
|
auth_required: true,
|
|
}).health(),
|
|
).rejects.toMatchObject({ code: 'CONTRACT' });
|
|
});
|
|
it('cannot present copied gateway scalars as live telemetry', async () => {
|
|
const row = await adapter({
|
|
version: '1',
|
|
gateway_running: true,
|
|
active_agents: 12,
|
|
gateway_state: 'running',
|
|
overall: 'ok',
|
|
provenance,
|
|
}).status('default');
|
|
expect(row).toMatchObject({
|
|
gateway_running: false,
|
|
active_agents: 0,
|
|
gateway_state: null,
|
|
overall: 'unknown',
|
|
liveGatewayState: 'unknown',
|
|
liveActiveAgents: null,
|
|
provenance,
|
|
});
|
|
});
|
|
it('profile readiness cannot be inferred from copied PID state', async () => {
|
|
const rows = await adapter({
|
|
profiles: [
|
|
{
|
|
name: 'default',
|
|
is_default: true,
|
|
gateway_running: true,
|
|
provenance,
|
|
},
|
|
],
|
|
provenance,
|
|
}).profiles();
|
|
expect(rows[0]).toMatchObject({
|
|
gateway_running: false,
|
|
liveGatewayState: 'unknown',
|
|
provenance,
|
|
});
|
|
});
|
|
});
|