|
@@ -879,88 +879,6 @@ describe("Bus", () => {
|
|
|
}),
|
|
}),
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- it.effect("replayAll validates contiguous aggregate events", () =>
|
|
|
|
|
- Effect.gen(function* () {
|
|
|
|
|
- const bus = yield* Bus.Service
|
|
|
|
|
- const aggregateID = Session.ID.create()
|
|
|
|
|
- const source = yield* bus.replayAll([
|
|
|
|
|
- {
|
|
|
|
|
- id: Event.ID.create(),
|
|
|
|
|
- created: DateTime.makeUnsafe(0),
|
|
|
|
|
- type: Bus.versionedType(DurableMessage.type, 1),
|
|
|
|
|
- seq: 0,
|
|
|
|
|
- aggregateID,
|
|
|
|
|
- data: durableData(aggregateID, "one"),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: Event.ID.create(),
|
|
|
|
|
- created: DateTime.makeUnsafe(0),
|
|
|
|
|
- type: Bus.versionedType(DurableMessage.type, 1),
|
|
|
|
|
- seq: 1,
|
|
|
|
|
- aggregateID,
|
|
|
|
|
- data: durableData(aggregateID, "two"),
|
|
|
|
|
- },
|
|
|
|
|
- ])
|
|
|
|
|
-
|
|
|
|
|
- expect(source).toBe(aggregateID)
|
|
|
|
|
- }),
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- it.effect("replayAll accepts later chunks after the first batch", () =>
|
|
|
|
|
- Effect.gen(function* () {
|
|
|
|
|
- const bus = yield* Bus.Service
|
|
|
|
|
- const { db } = yield* Database.Service
|
|
|
|
|
- const aggregateID = Session.ID.create()
|
|
|
|
|
-
|
|
|
|
|
- const one = yield* bus.replayAll([
|
|
|
|
|
- {
|
|
|
|
|
- id: Event.ID.create(),
|
|
|
|
|
- created: DateTime.makeUnsafe(0),
|
|
|
|
|
- type: Bus.versionedType(DurableMessage.type, 1),
|
|
|
|
|
- seq: 0,
|
|
|
|
|
- aggregateID,
|
|
|
|
|
- data: durableData(aggregateID, "one"),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: Event.ID.create(),
|
|
|
|
|
- created: DateTime.makeUnsafe(0),
|
|
|
|
|
- type: Bus.versionedType(DurableMessage.type, 1),
|
|
|
|
|
- seq: 1,
|
|
|
|
|
- aggregateID,
|
|
|
|
|
- data: durableData(aggregateID, "two"),
|
|
|
|
|
- },
|
|
|
|
|
- ])
|
|
|
|
|
- const two = yield* bus.replayAll([
|
|
|
|
|
- {
|
|
|
|
|
- id: Event.ID.create(),
|
|
|
|
|
- created: DateTime.makeUnsafe(0),
|
|
|
|
|
- type: Bus.versionedType(DurableMessage.type, 1),
|
|
|
|
|
- seq: 2,
|
|
|
|
|
- aggregateID,
|
|
|
|
|
- data: durableData(aggregateID, "three"),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: Event.ID.create(),
|
|
|
|
|
- created: DateTime.makeUnsafe(0),
|
|
|
|
|
- type: Bus.versionedType(DurableMessage.type, 1),
|
|
|
|
|
- seq: 3,
|
|
|
|
|
- aggregateID,
|
|
|
|
|
- data: durableData(aggregateID, "four"),
|
|
|
|
|
- },
|
|
|
|
|
- ])
|
|
|
|
|
- const rows = yield* db
|
|
|
|
|
- .select()
|
|
|
|
|
- .from(EventTable)
|
|
|
|
|
- .where(eq(EventTable.aggregate_id, aggregateID))
|
|
|
|
|
- .all()
|
|
|
|
|
- .pipe(Effect.orDie)
|
|
|
|
|
-
|
|
|
|
|
- expect(one).toBe(aggregateID)
|
|
|
|
|
- expect(two).toBe(aggregateID)
|
|
|
|
|
- expect(rows.map((row) => row.seq)).toEqual([0, 1, 2, 3])
|
|
|
|
|
- }),
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
it.effect("claim fences replay owners", () =>
|
|
it.effect("claim fences replay owners", () =>
|
|
|
Effect.gen(function* () {
|
|
Effect.gen(function* () {
|
|
|
const bus = yield* Bus.Service
|
|
const bus = yield* Bus.Service
|