16 lines
1.1 KiB
TypeScript
16 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { validateInventory } from '../../src/lib/server/hosts/index.js';
|
|
|
|
const update = { enabled: true, state: 'updated', currentVersion: '1.2.0', targetVersion: '1.2.0', checkedAt: '2026-10-04T12:00:00Z' };
|
|
describe('agent update inventory', () => {
|
|
it('accepts legacy inventory and only publishes recognized update display fields', () => {
|
|
expect(validateInventory({ protocolVersion: 1 })).toEqual({ protocolVersion: 1 });
|
|
expect(validateInventory({ agentUpdate: { ...update, credential: 'private', journal: { backups: 'local-path' } } }).agentUpdate).toEqual(update);
|
|
});
|
|
it.each([null, [], 'updated', { ...update, enabled: 'yes' }, { ...update, state: '<script>' },
|
|
{ ...update, currentVersion: {} }, { ...update, targetVersion: 'invalid' }, { ...update, checkedAt: 'invalid' },
|
|
{ ...update, error: {} }, { ...update, error: 'x'.repeat(2001) }])('rejects invalid update metadata %j', agentUpdate => {
|
|
expect(() => validateInventory({ agentUpdate })).toThrow('Invalid agent update inventory');
|
|
});
|
|
});
|