55 lines
1.7 KiB
Dart
55 lines
1.7 KiB
Dart
import 'package:cyberhybridhub/admin/models/sync_run_event.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('parses wire severity/status and title mapping', () {
|
|
final SyncRunEvent event = SyncRunEvent.fromJson(<String, dynamic>{
|
|
'id': 10,
|
|
'kind': 'backfill',
|
|
'startedAt': '2026-05-27T01:00:00Z',
|
|
'finishedAt': '2026-05-27T01:00:05Z',
|
|
'rowsWritten': 100,
|
|
'rowsRemoved': 0,
|
|
'error': null,
|
|
'severity': 'ok',
|
|
'status': 'success',
|
|
'durationMs': 5000,
|
|
'summary': '100 bar rows written',
|
|
});
|
|
|
|
expect(event.severity, SyncRunSeverity.ok);
|
|
expect(event.status, SyncRunStatus.success);
|
|
expect(event.displayTitle, 'Market history backfill');
|
|
});
|
|
|
|
test('falls back to rate-limit severity parsing', () {
|
|
final SyncRunEvent event = SyncRunEvent.fromJson(<String, dynamic>{
|
|
'id': 11,
|
|
'kind': 'backfill',
|
|
'startedAt': '2026-05-27T01:00:00Z',
|
|
'finishedAt': '2026-05-27T01:00:05Z',
|
|
'rowsWritten': 0,
|
|
'rowsRemoved': 0,
|
|
'error': 'AlpacaMarketDataException rate limited: 429',
|
|
});
|
|
|
|
expect(event.severity, SyncRunSeverity.rateLimit);
|
|
expect(event.status, SyncRunStatus.failed);
|
|
});
|
|
|
|
test('falls back to partial status when rows written and error', () {
|
|
final SyncRunEvent event = SyncRunEvent.fromJson(<String, dynamic>{
|
|
'id': 12,
|
|
'kind': 'backfill',
|
|
'startedAt': '2026-05-27T01:00:00Z',
|
|
'finishedAt': '2026-05-27T01:00:05Z',
|
|
'rowsWritten': 33,
|
|
'rowsRemoved': 0,
|
|
'error': 'batch failed',
|
|
});
|
|
|
|
expect(event.status, SyncRunStatus.partial);
|
|
expect(event.summary, contains('Partial success'));
|
|
});
|
|
}
|