Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -1,15 +1,38 @@
|
||||
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' };
|
||||
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);
|
||||
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 => {
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user