0.16.0
🚀 What's New
1. Added PostgreSQL and Pongo Projection specification for integration testing
Now you can write your tests as:
const given = PostgreSQLProjectionSpec.for({
projection: shoppingCartShortInfoProjection,
connectionString,
});
test('with empty given and when eventsInStream',
given(
eventsInStream<ProductItemAdded>(shoppingCartId, [
{
type: 'ProductItemAdded',
data: {
productItem: { price: 100, productId: 'shoes', quantity: 100 },
},
},
]),
)
.when(
newEventsInStream(shoppingCartId, [
{
type: 'DiscountApplied',
data: { percent: 10 },
},
]),
)
.then(
expectPongoDocuments
.fromCollection(shoppingCartShortInfoCollectionName)
.withId(shoppingCartId)
.toBeEqual({
productItemsCount: 100,
totalAmount: 9000,
}),
);
});
There are also other helpers; you can also check raw projections using helpers like assertSQLQueryResultMatches
.
by @oskardudycz in #105
2. Refactored Postgres projections registrations
- Separated projection definition from registration. Thanks to that, projections will be able to switch their type in the future or be used in both (e.g., for rebuilds).
- Refactored projections to take params object instead of a list of parameters. That will cut the number of permutations and make it easier to define them
- Renamed
pongoSingleProjection
topongoSingleStreamProjection
to keep naming consistency.
Now, registration will look like this (notice projections.inline
helper):
import { projections } from '@event-driven-io/emmett';
const eventStore = getPostgreSQLEventStore(connectionString, {
projections: projections.inline(
[shoppingCartShortInfoProjection, customProjection]
),
});
And Pongo projection definition as:
const shoppingCartShortInfoProjection = pongoSingleStreamProjection({
collectionName: 'shoppingCartsShortInfo',
evolve,
canHandle: ['ProductItemAdded', 'DiscountApplied'],
});
by @oskardudycz in #104
📝 What’s Changed
- Updated Pongo to 0.12.5 by @oskardudycz in #103, #105
Full Changelog: 0.15.0...0.16.0