import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/schedules/data/schedules_repository.dart'; import 'schedule_test_support.dart'; void main() { test( 'list rejects non-positive and unsafe pipeline IDs before sending', () async { final gateway = RecordingGateway(); final repository = SchedulesRepository(gateway); for (final id in [0, -1, 9007199254740992]) { await expectLater( repository.listSchedules(pipelineId: id), throwsA( isA().having( (error) => error.message, 'message', 'A positive pipeline ID is required.', ), ), ); } expect(gateway.calls, isEmpty); }, ); test( 'delete rejects an inexact identity or revision before sending', () async { final gateway = RecordingGateway(); final repository = SchedulesRepository(gateway); for (final pair in [ (0, 1), (-1, 1), (8, 0), (8, -1), (8, 9007199254740992), ]) { await expectLater( repository.deleteSchedule(pair.$1, pair.$2), throwsA( isA().having( (error) => error.message, 'message', 'An exact schedule ID and revision are required.', ), ), ); } expect(gateway.calls, isEmpty); }, ); test( 'request keys are bounded at 128 characters like the web client', () async { final gateway = RecordingGateway(); final repository = SchedulesRepository(gateway); await expectLater( repository.saveSchedule(createRecord(), requestKey: 'x' * 129), throwsA( isA().having( (error) => error.message, 'message', 'Schedule request keys must be strings of at most 128 characters.', ), ), ); expect(gateway.calls, isEmpty); final key = 'x' * 128; gateway.replies.add({'type': 'schedule', 'schedule': savedRecord()}); await repository.saveSchedule(createRecord(), requestKey: key); expect(gateway.calls.single.fields['request_key'], key); }, ); }