Test: adding checkpoint for passing test
This commit is contained in:
parent
96984ea7da
commit
5e25d7729d
1 changed files with 24 additions and 0 deletions
|
@ -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<EventBus>()).thenReturn(true);
|
||||
when(container.has<TransactionManager>()).thenReturn(false);
|
||||
when(container.make<EventBus>()).thenReturn(eventBus);
|
||||
|
@ -51,6 +57,14 @@ void main() {
|
|||
expect(() => queue.createPayload({}, 'test_queue'),
|
||||
throwsA(isA<InvalidPayloadException>()));
|
||||
});
|
||||
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 {}
|
||||
|
|
Loading…
Reference in a new issue