From 5e25d7729d26c24038c26e42aa4737ca583eaf35 Mon Sep 17 00:00:00 2001 From: Patrick Stewart Date: Sat, 5 Oct 2024 21:06:00 -0700 Subject: [PATCH] Test: adding checkpoint for passing test --- core/queue/test/queue_test.dart | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/queue/test/queue_test.dart b/core/queue/test/queue_test.dart index f5e2568a..607666e0 100644 --- a/core/queue/test/queue_test.dart +++ b/core/queue/test/queue_test.dart @@ -5,6 +5,8 @@ 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 'package:angel3_queue/src/should_queue_after_commit.dart'; //import 'package:angel3_queue/src/invalid_payload_exception.dart'; import 'queue_test.mocks.dart'; @@ -25,6 +27,10 @@ void main() { mq = MockMQClient(); queue = TestQueue(container, eventBus, mq); + // Inject the other mocks into the queue + // queue.container = container; + // queue.mq = mq; + when(container.has()).thenReturn(true); when(container.has()).thenReturn(false); when(container.make()).thenReturn(eventBus); @@ -51,6 +57,14 @@ void main() { expect(() => queue.createPayload({}, 'test_queue'), throwsA(isA())); }); + test('shouldDispatchAfterCommit returns correct value', () { + expect( + queue.shouldDispatchAfterCommit(MockShouldQueueAfterCommit()), isTrue); + expect(queue.shouldDispatchAfterCommit({}), isFalse); + + queue.dispatchAfterCommit = true; + expect(queue.shouldDispatchAfterCommit({}), isTrue); + }); } class TestQueue extends Queue { @@ -79,6 +93,14 @@ class TestQueue extends Queue { } return 'valid payload'; } + + @override + bool shouldDispatchAfterCommit(dynamic job) { + if (job is ShouldQueueAfterCommit) { + return true; + } + return dispatchAfterCommit; + } } class DummyEventBus implements EventBus { @@ -92,3 +114,5 @@ class InvalidPayloadException implements Exception { @override String toString() => 'InvalidPayloadException: $message'; } + +class MockShouldQueueAfterCommit implements ShouldQueueAfterCommit {}