Skip to content

Commit

Permalink
fix(eventstore): lowercase method - appendToStream
Browse files Browse the repository at this point in the history
This would be a breaking change if I was already versioning properly, but meh...

Fixes #255
  • Loading branch information
YannickMeeus committed Sep 21, 2020
1 parent e868021 commit f9d2d49
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/EventStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class EventStore {
* @returns {Promise<void>}
* @memberof EventStore
*/
public AppendToStream(
public appendToStream(
streamId: string,
expectedVersion: number,
...events: EventData[]
Expand Down
28 changes: 14 additions & 14 deletions test/EventStore.Appending.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Given a set of engines to test against', () => {

const newGuid = () => uuid.v4()

engineFactories.forEach(getEngine => {
engineFactories.forEach((getEngine) => {
const engine = getEngine()

const getStore = async () => {
Expand All @@ -22,12 +22,12 @@ describe('Given a set of engines to test against', () => {
describe('When appending to a new stream', () => {
describe('And the stream id is invalid', () => {
const invalidStreamIds = [undefined, null, '', ' ']
invalidStreamIds.forEach(invalidStreamId => {
invalidStreamIds.forEach((invalidStreamId) => {
it(`It should throw an error for stream id: '${invalidStreamId}'`, async () => {
const eventStore = await getStore()
const event = new EventData(newGuid(), 'BODY')
try {
await eventStore.AppendToStream(invalidStreamId as string, 0, event)
await eventStore.appendToStream(invalidStreamId as string, 0, event)
} catch (e) {
expect(e.message).toEqual(
'streamId can not be null, empty string or contain only whitespace'
Expand All @@ -44,7 +44,7 @@ describe('Given a set of engines to test against', () => {

it('It should save both events and allow them to be retrievable', async () => {
const sut = await getStore()
await sut.AppendToStream(streamId, 0, ...eventsToSave)
await sut.appendToStream(streamId, 0, ...eventsToSave)

const savedEvents = await sut.readStreamForwards(streamId)

Expand All @@ -64,7 +64,7 @@ describe('Given a set of engines to test against', () => {
const sut = await getStore()
const event = new EventData(newGuid(), new OrderCreated(streamId))

await sut.AppendToStream(streamId, 0, event)
await sut.appendToStream(streamId, 0, event)

const stream = await sut.readStreamForwards(streamId)
expect(stream.length).toEqual(1)
Expand All @@ -79,14 +79,14 @@ describe('Given a set of engines to test against', () => {
}

const metaData: SomeMetaData = {
value: 'foo'
value: 'foo',
}

const streamId = newGuid()
const sut = await getStore()
const event = new EventData(newGuid(), new OrderCreated(streamId), metaData)

await sut.AppendToStream(streamId, 0, event)
await sut.appendToStream(streamId, 0, event)
const stream = await sut.readStreamForwards(streamId)
const savedEvent = stream.pop() as EventStorage
expect(savedEvent.metaData as SomeMetaData).toEqual(metaData)
Expand All @@ -98,9 +98,9 @@ describe('Given a set of engines to test against', () => {
const sut = await getStore()
const firstEvent = new EventData(newGuid(), new OrderCreated(streamId))
const secondEvent = new EventData(newGuid(), new OrderDispatched(streamId))
await sut.AppendToStream(streamId, 0, firstEvent)
await sut.appendToStream(streamId, 0, firstEvent)

await sut.AppendToStream(streamId, 1, secondEvent)
await sut.appendToStream(streamId, 1, secondEvent)

const stream = await sut.readStreamForwards(streamId)

Expand All @@ -112,29 +112,29 @@ describe('Given a set of engines to test against', () => {
})
describe('When appending to a new stream with an unexpected version', () => {
const invalidRevisions = [-1, 1, 2, 99]
invalidRevisions.forEach(invalidRevision => {
invalidRevisions.forEach((invalidRevision) => {
it(`It should throw a concurrency error with revision number: '${invalidRevision}'`, async () => {
const streamId = newGuid()
const sut = await getStore()
const event = new EventData(newGuid(), new OrderDispatched(streamId))

await expect(sut.AppendToStream(streamId, invalidRevision, event)).rejects.toThrow(
await expect(sut.appendToStream(streamId, invalidRevision, event)).rejects.toThrow(
'Concurrency conflict'
)
})
})
})
describe('When appending to an existing stream with an unexpected version', () => {
const invalidRevisions = [0, 2]
invalidRevisions.forEach(invalidRevision => {
invalidRevisions.forEach((invalidRevision) => {
it(`It should throw a concurrency error with revision number: '${invalidRevision}'`, async () => {
const streamId = newGuid()
const sut = await getStore()

const existingEvent = new EventData(newGuid(), new OrderCreated(streamId))
const newEvent = new EventData(newGuid(), new OrderDispatched(streamId))
await sut.AppendToStream(streamId, 0, existingEvent)
await expect(sut.AppendToStream(streamId, invalidRevision, newEvent)).rejects.toThrow(
await sut.appendToStream(streamId, 0, existingEvent)
await expect(sut.appendToStream(streamId, invalidRevision, newEvent)).rejects.toThrow(
'Concurrency conflict'
)
})
Expand Down
4 changes: 2 additions & 2 deletions test/EventStore.Deleting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ describe('Given a set of engines to test against', () => {
const firstEvent = new EventData(newGuid(), new OrderCreated(streamId))
const secondEvent = new EventData(newGuid(), new OrderDispatched(streamId))

await sut.AppendToStream(streamId, 0, firstEvent)
await sut.AppendToStream(streamId, 1, secondEvent)
await sut.appendToStream(streamId, 0, firstEvent)
await sut.appendToStream(streamId, 1, secondEvent)

const stream = await sut.readStreamForwards(streamId)

Expand Down
8 changes: 4 additions & 4 deletions test/EventStore.Reading.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ describe('Given a set of engines to test against', () => {
const firstEvent = new EventData(newGuid(), new OrderCreated(streamId))
const secondEvent = new EventData(newGuid(), new OrderDispatched(streamId))

await sut.AppendToStream(streamId, 0, firstEvent)
await sut.AppendToStream(streamId, 1, secondEvent)
await sut.appendToStream(streamId, 0, firstEvent)
await sut.appendToStream(streamId, 1, secondEvent)

const stream = await sut.readStreamForwards(streamId)

Expand All @@ -64,8 +64,8 @@ describe('Given a set of engines to test against', () => {
const firstEvent = new EventData(newGuid(), new OrderCreated(streamId))
const secondEvent = new EventData(newGuid(), new OrderDispatched(streamId))

await sut.AppendToStream(streamId, 0, firstEvent)
await sut.AppendToStream(streamId, 1, secondEvent)
await sut.appendToStream(streamId, 0, firstEvent)
await sut.appendToStream(streamId, 1, secondEvent)

const subsetOfStream = await sut.readStreamForwards(streamId, 2, 1)

Expand Down

0 comments on commit f9d2d49

Please sign in to comment.