A library with utilities for testing eventuous
You can test Eventuous with StreamEventStore running in-memory or running as en external process.
A simple usage example for testing applications without any external processes:
pubspec.yaml
dev_dependencies:
// Needed for testing Eventuous
eventuous_test: any
main.dart
import 'package:eventuous/eventuous.dart';
import 'package:eventuous_test/eventuous_test.dart';
import 'package:test/test.dart';
// TODO: Implement your own aggregate store, this is only indicative
typedef FooStore = AggregateStore<
JsonMap,
JsonObject,
JsonObject,
AggregateId,
AggregateState<JsonObject>,
Aggregate<JsonObject, JsonObject, AggregateId, AggregateState<JsonObject>>>;
void main() {
test('test aggregate store with InMemoryEventStore', () {
// Create a StreamEventStore using eventuous_test
final eventStore = InMemoryEventStore();
// Create some aggregate store with in-memory event store
// ignore: unused_local_variable
final FooStore = FooStore(
eventStore,
// TODO: onNew: (id, [state]) => Foo(id, state),
);
// Do some testing here...
});
}
A simple usage example for testing applications with EventStoreDB locally:
pubspec.yaml
dev_dependencies:
// Needed for testing Eventuous
eventuous_test: any
// Needed for testing with EventStoreDB running locally in Docker
eventstore_client_test: any
main.dart
import 'package:eventuous/eventuous.dart';
import 'package:eventuous_test/eventuous_test.dart';
import 'package:test/test.dart';
// TODO: Implement your own aggregate store, this is only indicative
typedef FooStore = AggregateStore<
JsonMap,
JsonObject,
JsonObject,
AggregateId,
AggregateState<JsonObject>,
Aggregate<JsonObject, JsonObject, AggregateId, AggregateState<JsonObject>>>;
void main() {
// Reusable test resources
late EventStoreStreamsClient client;
late EventStoreServerSingleNode server;
setUpAll(() {
server = EventStoreServerSingleNode();
client = EventStoreStreamsClient(
EventStoreClientSettings.parse('esdb://127.0.0.1:2113?tls=false'),
);
return server.start();
});
tearDownAll(() async {
await client.shutdown();
await server.stop();
});
test('test aggregate store with EventStoreDB', () {
// Create some aggregate store with EventStoreDB event store
// ignore: unused_local_variable
final FooStore = FooStore(
server,
// TODO: onNew: (id, [state]) => Foo(id, state),
);
// Do some testing here...
});
}
The examples above are not complete. You should use eventuous_generator to generate your own aggregate implementation.
Please file feature requests and bugs at the issue tracker.