- P2: nonce validation, severity levels, RLS withTenant - P3: notification dispatcher severity gating, Slack Block Kit emoji mapping - P4: Meilisearch fallback, service CRUD validation, staged update actions - P5: cost ingestion validation, snooze range, optimistic locking - P6: runbook API validation, approval decisions, execution status machine, Slack signature
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
|
|
describe('Cost Ingestion Validation', () => {
|
|
it('rejects negative hourly cost', () => {
|
|
const cost = -5.00;
|
|
expect(cost >= 0).toBe(false);
|
|
});
|
|
|
|
it('accepts zero cost', () => {
|
|
const cost = 0;
|
|
expect(cost >= 0).toBe(true);
|
|
});
|
|
|
|
it('batch size limited to 100', () => {
|
|
const events = Array.from({ length: 101 }, (_, i) => ({ account_id: 'a', resource_type: 'ec2', hourly_cost: i }));
|
|
expect(events.length <= 100).toBe(false);
|
|
|
|
const validBatch = events.slice(0, 100);
|
|
expect(validBatch.length <= 100).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('Anomaly Snooze', () => {
|
|
it('accepts 1-168 hour range', () => {
|
|
expect(1 >= 1 && 1 <= 168).toBe(true);
|
|
expect(168 >= 1 && 168 <= 168).toBe(true);
|
|
expect(0 >= 1).toBe(false);
|
|
expect(169 <= 168).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('Optimistic Locking', () => {
|
|
it('detects version conflict', () => {
|
|
const currentVersion = 5;
|
|
const expectedVersion = 4; // Stale read
|
|
expect(currentVersion === expectedVersion).toBe(false);
|
|
});
|
|
|
|
it('allows update when versions match', () => {
|
|
const currentVersion = 5;
|
|
const expectedVersion = 5;
|
|
expect(currentVersion === expectedVersion).toBe(true);
|
|
});
|
|
});
|