import 'package:test/test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:angel3_container/angel3_container.dart'; import 'package:angel3_event_bus/event_bus.dart'; import 'package:angel3_mq/mq.dart'; import 'package:angel3_queue/src/queue.dart'; import 'queue_test.mocks.dart'; @GenerateMocks([Container, MQClient, TransactionManager]) void main() { late MockContainer container; late EventBus eventBus; late MockMQClient mq; late TestQueue queue; setUpAll(() { // Provide a dummy EventBus for Mockito to use provideDummy(DummyEventBus()); }); setUp(() { container = MockContainer(); eventBus = DummyEventBus(); mq = MockMQClient(); queue = TestQueue(container, eventBus, mq); // Basic setup when(container.has()).thenReturn(true); when(container.has()).thenReturn(false); when(container.make()).thenReturn(eventBus); }); test('pushOn calls push with correct arguments', () async { final result = await queue.pushOn('test_queue', 'test_job', 'test_data'); expect(result, equals('pushed')); }); test('laterOn calls later with correct arguments', () async { final result = await queue.laterOn( 'test_queue', Duration(minutes: 5), 'test_job', 'test_data'); expect(result, equals('pushed later')); }); } class TestQueue extends Queue { TestQueue(Container container, EventBus eventBus, MQClient mq) : super(container, eventBus, mq); @override Future push(dynamic job, [dynamic data = '', String? queue]) async { return 'pushed'; } @override Future later(Duration delay, dynamic job, [dynamic data = '', String? queue]) async { return 'pushed later'; } } class DummyEventBus implements EventBus { @override dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); }