Update tests, typescript declaration
This commit is contained in:
parent
e6af223f0d
commit
4584517ede
22
index.d.ts
vendored
22
index.d.ts
vendored
|
@ -16,7 +16,7 @@ export class UserCredentials {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PersistentSubscriptionSettings {
|
export class PersistentSubscriptionSettings {
|
||||||
constructor(resolveLinkTos: boolean, startFrom: number, extraStatistics: boolean, messageTimeout: number,
|
constructor(resolveLinkTos: boolean, startFrom: Long|number, extraStatistics: boolean, messageTimeout: number,
|
||||||
maxRetryCount: number, liveBufferSize: number, readBatchSize: number, historyBufferSize: number,
|
maxRetryCount: number, liveBufferSize: number, readBatchSize: number, historyBufferSize: number,
|
||||||
checkPointAfter: number, minCheckPointCount: number, maxCheckPointCount: number,
|
checkPointAfter: number, minCheckPointCount: number, maxCheckPointCount: number,
|
||||||
maxSubscriberCount: number, namedConsumerStrategy: string)
|
maxSubscriberCount: number, namedConsumerStrategy: string)
|
||||||
|
@ -108,7 +108,7 @@ export interface WriteResult {
|
||||||
export interface RecordedEvent {
|
export interface RecordedEvent {
|
||||||
readonly eventStreamId: string;
|
readonly eventStreamId: string;
|
||||||
readonly eventId: string;
|
readonly eventId: string;
|
||||||
readonly eventNumber: number;
|
readonly eventNumber: Long;
|
||||||
readonly eventType: string;
|
readonly eventType: string;
|
||||||
readonly createdEpoch: number;
|
readonly createdEpoch: number;
|
||||||
readonly data?: Buffer;
|
readonly data?: Buffer;
|
||||||
|
@ -123,17 +123,17 @@ export interface ResolvedEvent {
|
||||||
readonly isResolved: boolean;
|
readonly isResolved: boolean;
|
||||||
readonly originalPosition?: Position;
|
readonly originalPosition?: Position;
|
||||||
readonly originalStreamId: string;
|
readonly originalStreamId: string;
|
||||||
readonly originalEventNumber: number;
|
readonly originalEventNumber: Long;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StreamEventsSlice {
|
export interface StreamEventsSlice {
|
||||||
readonly status: string; // TODO: enum
|
readonly status: string; // TODO: enum
|
||||||
readonly stream: string;
|
readonly stream: string;
|
||||||
readonly fromEventNumber: number;
|
readonly fromEventNumber: Long;
|
||||||
readonly readDirection: string; // TODO: enum
|
readonly readDirection: string; // TODO: enum
|
||||||
readonly events: ResolvedEvent[];
|
readonly events: ResolvedEvent[];
|
||||||
readonly nextEventNumber: number;
|
readonly nextEventNumber: Long;
|
||||||
readonly lastEventNumber: number;
|
readonly lastEventNumber: Long;
|
||||||
readonly isEndOfStream: boolean;
|
readonly isEndOfStream: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ export interface EventStoreTransaction {
|
||||||
export interface EventReadResult {
|
export interface EventReadResult {
|
||||||
readonly status: string;
|
readonly status: string;
|
||||||
readonly stream: string;
|
readonly stream: string;
|
||||||
readonly eventNumber: number;
|
readonly eventNumber: Long;
|
||||||
readonly event: ResolvedEvent | null;
|
readonly event: ResolvedEvent | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ export interface EventStoreSubscription {
|
||||||
readonly isSubscribedToAll: boolean;
|
readonly isSubscribedToAll: boolean;
|
||||||
readonly streamId: string;
|
readonly streamId: string;
|
||||||
readonly lastCommitPosition: Position;
|
readonly lastCommitPosition: Position;
|
||||||
readonly lastEventNumber: number;
|
readonly lastEventNumber: Long;
|
||||||
|
|
||||||
close(): void;
|
close(): void;
|
||||||
unsubscribe(): void;
|
unsubscribe(): void;
|
||||||
|
@ -254,9 +254,9 @@ export interface EventStoreNodeConnection {
|
||||||
startTransaction(stream: string, expectedVersion: Long|number, userCredentials?: UserCredentials): Promise<EventStoreTransaction>;
|
startTransaction(stream: string, expectedVersion: Long|number, userCredentials?: UserCredentials): Promise<EventStoreTransaction>;
|
||||||
continueTransaction(transactionId: number, userCredentials?: UserCredentials): EventStoreTransaction;
|
continueTransaction(transactionId: number, userCredentials?: UserCredentials): EventStoreTransaction;
|
||||||
// read actions
|
// read actions
|
||||||
readEvent(stream: string, eventNumber: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<EventReadResult>;
|
readEvent(stream: string, eventNumber: Long|number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<EventReadResult>;
|
||||||
readStreamEventsForward(stream: string, start: number, count: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<StreamEventsSlice>;
|
readStreamEventsForward(stream: string, start: Long|number, count: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<StreamEventsSlice>;
|
||||||
readStreamEventsBackward(stream: string, start: number, count: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<StreamEventsSlice>;
|
readStreamEventsBackward(stream: string, start: Long|number, count: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<StreamEventsSlice>;
|
||||||
readAllEventsForward(position: Position, maxCount: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<AllEventsSlice>;
|
readAllEventsForward(position: Position, maxCount: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<AllEventsSlice>;
|
||||||
readAllEventsBackward(position: Position, maxCount: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<AllEventsSlice>;
|
readAllEventsBackward(position: Position, maxCount: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<AllEventsSlice>;
|
||||||
// subscription actions
|
// subscription actions
|
||||||
|
|
|
@ -12,10 +12,11 @@ module.exports.notNull = function(value, name) {
|
||||||
throw new TypeError(name + " should not be null.");
|
throw new TypeError(name + " should not be null.");
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.isInteger = function isInteger(value, name) {
|
function isInteger(value, name) {
|
||||||
if (typeof value !== 'number' || value % 1 !== 0)
|
if (typeof value !== 'number' || value % 1 !== 0)
|
||||||
throw new TypeError(name + " should be an integer.");
|
throw new TypeError(name + " should be an integer.");
|
||||||
};
|
}
|
||||||
|
module.exports.isInteger = isInteger;
|
||||||
|
|
||||||
module.exports.isLongOrInteger = function(value, name) {
|
module.exports.isLongOrInteger = function(value, name) {
|
||||||
if (typeof value === 'number') {
|
if (typeof value === 'number') {
|
||||||
|
|
|
@ -407,7 +407,7 @@ EventStoreConnectionLogicHandler.prototype._goToIdentifiedState = function() {
|
||||||
};
|
};
|
||||||
var dto = new ClientMessage.IdentifyClient({version: ClientVersion, connectionName: this._esConnection.connectionName});
|
var dto = new ClientMessage.IdentifyClient({version: ClientVersion, connectionName: this._esConnection.connectionName});
|
||||||
var buf = dto.constructor.encode(dto).finish();
|
var buf = dto.constructor.encode(dto).finish();
|
||||||
this._connection.enqueueSend(new TcpPackage(TcpCommand.IdentifyClient, this._identityInfo.correlationId, null, null, createBufferSegment(buf)))
|
this._connection.enqueueSend(new TcpPackage(TcpCommand.IdentifyClient, TcpFlags.None, this._identityInfo.correlationId, null, null, createBufferSegment(buf)))
|
||||||
};
|
};
|
||||||
|
|
||||||
EventStoreConnectionLogicHandler.prototype._goToConnectedState = function() {
|
EventStoreConnectionLogicHandler.prototype._goToConnectedState = function() {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var uuid = require('uuid');
|
var uuid = require('uuid');
|
||||||
|
var Long = require('long');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var ensure = require('./common/utils/ensure');
|
var ensure = require('./common/utils/ensure');
|
||||||
|
|
||||||
|
@ -269,7 +270,7 @@ EventStoreNodeConnection.prototype.readEvent = function(stream, eventNumber, res
|
||||||
* Reading a specific stream forwards (async)
|
* Reading a specific stream forwards (async)
|
||||||
* @public
|
* @public
|
||||||
* @param {string} stream
|
* @param {string} stream
|
||||||
* @param {number} start
|
* @param {Long|number} start
|
||||||
* @param {number} count
|
* @param {number} count
|
||||||
* @param {boolean} [resolveLinkTos]
|
* @param {boolean} [resolveLinkTos]
|
||||||
* @param {UserCredentials} [userCredentials]
|
* @param {UserCredentials} [userCredentials]
|
||||||
|
@ -279,7 +280,8 @@ EventStoreNodeConnection.prototype.readStreamEventsForward = function(
|
||||||
stream, start, count, resolveLinkTos, userCredentials
|
stream, start, count, resolveLinkTos, userCredentials
|
||||||
) {
|
) {
|
||||||
ensure.notNullOrEmpty(stream, "stream");
|
ensure.notNullOrEmpty(stream, "stream");
|
||||||
ensure.isInteger(start, "start");
|
ensure.isLongOrInteger(start, "start");
|
||||||
|
start = Long.fromValue(start);
|
||||||
ensure.nonNegative(start, "start");
|
ensure.nonNegative(start, "start");
|
||||||
ensure.isInteger(count, "count");
|
ensure.isInteger(count, "count");
|
||||||
ensure.positive(count, "count");
|
ensure.positive(count, "count");
|
||||||
|
@ -303,7 +305,7 @@ EventStoreNodeConnection.prototype.readStreamEventsForward = function(
|
||||||
* Reading a specific stream backwards (async)
|
* Reading a specific stream backwards (async)
|
||||||
* @public
|
* @public
|
||||||
* @param {string} stream
|
* @param {string} stream
|
||||||
* @param {number} start
|
* @param {Long|number} start
|
||||||
* @param {number} count
|
* @param {number} count
|
||||||
* @param {boolean} [resolveLinkTos]
|
* @param {boolean} [resolveLinkTos]
|
||||||
* @param {UserCredentials} [userCredentials]
|
* @param {UserCredentials} [userCredentials]
|
||||||
|
@ -313,7 +315,8 @@ EventStoreNodeConnection.prototype.readStreamEventsBackward = function(
|
||||||
stream, start, count, resolveLinkTos, userCredentials
|
stream, start, count, resolveLinkTos, userCredentials
|
||||||
) {
|
) {
|
||||||
ensure.notNullOrEmpty(stream, "stream");
|
ensure.notNullOrEmpty(stream, "stream");
|
||||||
ensure.isInteger(start, "start");
|
ensure.isLongOrInteger(start, "start");
|
||||||
|
start = Long.fromValue(start);
|
||||||
ensure.isInteger(count, "count");
|
ensure.isInteger(count, "count");
|
||||||
ensure.positive(count, "count");
|
ensure.positive(count, "count");
|
||||||
if (count > MaxReadSize) throw new Error(util.format("Count should be less than %d. For larger reads you should page.", MaxReadSize));
|
if (count > MaxReadSize) throw new Error(util.format("Count should be less than %d. For larger reads you should page.", MaxReadSize));
|
||||||
|
|
|
@ -841,6 +841,7 @@
|
||||||
if (!(reader instanceof $Reader))
|
if (!(reader instanceof $Reader))
|
||||||
reader = $Reader.create(reader);
|
reader = $Reader.create(reader);
|
||||||
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EventStore.Client.Messages.ResolvedIndexedEvent();
|
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.EventStore.Client.Messages.ResolvedIndexedEvent();
|
||||||
|
message.event = null;
|
||||||
while (reader.pos < end) {
|
while (reader.pos < end) {
|
||||||
var tag = reader.uint32();
|
var tag = reader.uint32();
|
||||||
switch (tag >>> 3) {
|
switch (tag >>> 3) {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
var SystemConsumerStrategies = require('./systemConsumerStrategies');
|
var SystemConsumerStrategies = require('./systemConsumerStrategies');
|
||||||
|
var ensure = require('./common/utils/ensure');
|
||||||
|
var Long = require('long');
|
||||||
|
|
||||||
function PersistentSubscriptionSettings(
|
function PersistentSubscriptionSettings(
|
||||||
resolveLinkTos, startFrom, extraStatistics, messageTimeout,
|
resolveLinkTos, startFrom, extraStatistics, messageTimeout,
|
||||||
|
@ -6,6 +8,9 @@ function PersistentSubscriptionSettings(
|
||||||
checkPointAfter, minCheckPointCount, maxCheckPointCount,
|
checkPointAfter, minCheckPointCount, maxCheckPointCount,
|
||||||
maxSubscriberCount, namedConsumerStrategy
|
maxSubscriberCount, namedConsumerStrategy
|
||||||
) {
|
) {
|
||||||
|
ensure.isLongOrInteger(startFrom);
|
||||||
|
startFrom = Long.fromValue(startFrom);
|
||||||
|
|
||||||
this.resolveLinkTos = resolveLinkTos;
|
this.resolveLinkTos = resolveLinkTos;
|
||||||
this.startFrom = startFrom;
|
this.startFrom = startFrom;
|
||||||
this.extraStatistics = extraStatistics;
|
this.extraStatistics = extraStatistics;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var uuid = require('uuid');
|
var uuid = require('uuid');
|
||||||
var client = require('../src/client');
|
var client = require('../src/client');
|
||||||
|
var Long = require('long');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'Append One Event To Stream Happy Path': function(test) {
|
'Append One Event To Stream Happy Path': function(test) {
|
||||||
|
@ -7,7 +8,7 @@ module.exports = {
|
||||||
var event = client.createJsonEventData(uuid.v4(), {a: Math.random(), b: uuid.v4()}, null, 'testEvent');
|
var event = client.createJsonEventData(uuid.v4(), {a: Math.random(), b: uuid.v4()}, null, 'testEvent');
|
||||||
this.conn.appendToStream(this.testStreamName, client.expectedVersion.any, event)
|
this.conn.appendToStream(this.testStreamName, client.expectedVersion.any, event)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.areEqual("nextExpectedVersion", result.nextExpectedVersion, 0);
|
test.areEqual("nextExpectedVersion", result.nextExpectedVersion, Long.fromNumber(0));
|
||||||
test.ok(result.logPosition, "No log position in result.");
|
test.ok(result.logPosition, "No log position in result.");
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -27,7 +28,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
this.conn.appendToStream(this.testStreamName, client.expectedVersion.any, events)
|
this.conn.appendToStream(this.testStreamName, client.expectedVersion.any, events)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.areEqual("result.nextExpectedVersion", result.nextExpectedVersion, expectedVersion);
|
test.areEqual("result.nextExpectedVersion", result.nextExpectedVersion, Long.fromNumber(expectedVersion));
|
||||||
test.ok(result.logPosition, "No log position in result.");
|
test.ok(result.logPosition, "No log position in result.");
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -47,7 +48,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
this.conn.appendToStream(this.testStreamName, client.expectedVersion.any, events)
|
this.conn.appendToStream(this.testStreamName, client.expectedVersion.any, events)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.areEqual("result.nextExpectedVersion", result.nextExpectedVersion, expectedVersion);
|
test.areEqual("result.nextExpectedVersion", result.nextExpectedVersion, Long.fromNumber(expectedVersion));
|
||||||
test.ok(result.logPosition, "No log position in result.");
|
test.ok(result.logPosition, "No log position in result.");
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -62,7 +63,7 @@ module.exports = {
|
||||||
|
|
||||||
this.conn.appendToStream(this.testStreamName, client.expectedVersion.any, event)
|
this.conn.appendToStream(this.testStreamName, client.expectedVersion.any, event)
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.areEqual("result.nextExpectedVersion", result.nextExpectedVersion, 0);
|
test.areEqual("result.nextExpectedVersion", result.nextExpectedVersion, Long.fromNumber(0));
|
||||||
test.ok(result.logPosition, "No log position in result.");
|
test.ok(result.logPosition, "No log position in result.");
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
|
|
@ -78,7 +78,7 @@ function testLiveEvent(name, event, evNumber) {
|
||||||
this.ok(event.originalPosition instanceof client.Position, name + ".originalPosition is not an instance of Position");
|
this.ok(event.originalPosition instanceof client.Position, name + ".originalPosition is not an instance of Position");
|
||||||
this.ok(event.originalStreamId, name + ".originalStreamId not defined (or null)");
|
this.ok(event.originalStreamId, name + ".originalStreamId not defined (or null)");
|
||||||
if (typeof evNumber === 'number') {
|
if (typeof evNumber === 'number') {
|
||||||
this.ok(event.originalEventNumber === evNumber, name + '.originalEventNumber expected ' + evNumber + ' got ' + event.originalEventNumber);
|
this.ok(event.originalEventNumber.toNumber() === evNumber, name + '.originalEventNumber expected ' + evNumber + ' got ' + event.originalEventNumber);
|
||||||
} else {
|
} else {
|
||||||
this.ok(typeof event.originalEventNumber === 'number', name + ".originalEventNumber is not a number");
|
this.ok(typeof event.originalEventNumber === 'number', name + ".originalEventNumber is not a number");
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ function testReadEvent(name, event, evNumber) {
|
||||||
this.ok(event.originalPosition === null, name + ".originalPosition is not null");
|
this.ok(event.originalPosition === null, name + ".originalPosition is not null");
|
||||||
this.ok(event.originalStreamId, name + ".originalStreamId not defined (or null)");
|
this.ok(event.originalStreamId, name + ".originalStreamId not defined (or null)");
|
||||||
if (typeof evNumber === 'number') {
|
if (typeof evNumber === 'number') {
|
||||||
this.ok(event.originalEventNumber === evNumber, name + '.originalEventNumber expected ' + evNumber + ' got ' + event.originalEventNumber);
|
this.ok(event.originalEventNumber.toNumber() === evNumber, name + '.originalEventNumber expected ' + evNumber + ' got ' + event.originalEventNumber);
|
||||||
} else {
|
} else {
|
||||||
this.ok(typeof event.originalEventNumber === 'number', name + ".originalEventNumber is not a number");
|
this.ok(typeof event.originalEventNumber === 'number', name + ".originalEventNumber is not a number");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var uuid = require('uuid');
|
var uuid = require('uuid');
|
||||||
var client = require('../src/client');
|
var client = require('../src/client');
|
||||||
|
var Long = require('long');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setUp: function(cb) {
|
setUp: function(cb) {
|
||||||
|
@ -25,7 +25,7 @@ module.exports = {
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.areEqual('status', result.status, client.eventReadStatus.Success);
|
test.areEqual('status', result.status, client.eventReadStatus.Success);
|
||||||
test.areEqual('stream', result.stream, self.testStreamName);
|
test.areEqual('stream', result.stream, self.testStreamName);
|
||||||
test.areEqual('eventNumber', result.eventNumber, 0);
|
test.areEqual('eventNumber', result.eventNumber, Long.fromNumber(0));
|
||||||
test.ok(result.event !== null, "event is null.");
|
test.ok(result.event !== null, "event is null.");
|
||||||
test.ok(result.event.originalEvent !== null, "event.originalEvent is null.");
|
test.ok(result.event.originalEvent !== null, "event.originalEvent is null.");
|
||||||
var event = JSON.parse(result.event.originalEvent.data.toString());
|
var event = JSON.parse(result.event.originalEvent.data.toString());
|
||||||
|
@ -45,7 +45,7 @@ module.exports = {
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.areEqual('status', result.status, client.eventReadStatus.NoStream);
|
test.areEqual('status', result.status, client.eventReadStatus.NoStream);
|
||||||
test.areEqual('stream', result.stream, anotherStream);
|
test.areEqual('stream', result.stream, anotherStream);
|
||||||
test.areEqual('eventNumber', result.eventNumber, 0);
|
test.areEqual('eventNumber', result.eventNumber, Long.fromNumber(0));
|
||||||
test.areEqual('event', result.event, null);
|
test.areEqual('event', result.event, null);
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -63,7 +63,7 @@ module.exports = {
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.areEqual('status', result.status, client.eventReadStatus.StreamDeleted);
|
test.areEqual('status', result.status, client.eventReadStatus.StreamDeleted);
|
||||||
test.areEqual('stream', result.stream, self.testStreamName);
|
test.areEqual('stream', result.stream, self.testStreamName);
|
||||||
test.areEqual('eventNumber', result.eventNumber, 0);
|
test.areEqual('eventNumber', result.eventNumber, Long.fromNumber(0));
|
||||||
test.areEqual('event', result.event, null);
|
test.areEqual('event', result.event, null);
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -78,7 +78,7 @@ module.exports = {
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.areEqual('status', result.status, client.eventReadStatus.NotFound);
|
test.areEqual('status', result.status, client.eventReadStatus.NotFound);
|
||||||
test.areEqual('stream', result.stream, self.testStreamName);
|
test.areEqual('stream', result.stream, self.testStreamName);
|
||||||
test.areEqual('eventNumber', result.eventNumber, 1);
|
test.areEqual('eventNumber', result.eventNumber, Long.fromNumber(1));
|
||||||
test.areEqual('event', result.event, null);
|
test.areEqual('event', result.event, null);
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -124,7 +124,7 @@ module.exports = {
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.areEqual('status', result.status, client.eventReadStatus.Success);
|
test.areEqual('status', result.status, client.eventReadStatus.Success);
|
||||||
test.areEqual('stream', result.stream, self.testStreamName);
|
test.areEqual('stream', result.stream, self.testStreamName);
|
||||||
test.areEqual('eventNumber', result.eventNumber, 1);
|
test.areEqual('eventNumber', result.eventNumber, Long.fromNumber(1));
|
||||||
test.ok(result.event !== null, "event is null.");
|
test.ok(result.event !== null, "event is null.");
|
||||||
test.ok(result.event.originalEvent !== null, "event.originalEvent is null.");
|
test.ok(result.event.originalEvent !== null, "event.originalEvent is null.");
|
||||||
var event = JSON.parse(result.event.originalEvent.data.toString());
|
var event = JSON.parse(result.event.originalEvent.data.toString());
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var uuid = require('uuid');
|
var uuid = require('uuid');
|
||||||
var client = require('../src/client');
|
var client = require('../src/client');
|
||||||
|
var Long = require('long');
|
||||||
|
|
||||||
const streamSize = 100;
|
const streamSize = 100;
|
||||||
|
|
||||||
|
@ -22,15 +23,15 @@ module.exports = {
|
||||||
.then(function(slice) {
|
.then(function(slice) {
|
||||||
test.areEqual('slice.status', slice.status, client.eventReadStatus.Success);
|
test.areEqual('slice.status', slice.status, client.eventReadStatus.Success);
|
||||||
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
||||||
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, streamSize-1);
|
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, Long.fromNumber(streamSize-1));
|
||||||
test.areEqual('slice.readDirection', slice.readDirection, 'backward');
|
test.areEqual('slice.readDirection', slice.readDirection, 'backward');
|
||||||
test.areEqual('slice.nextEventNumber', slice.nextEventNumber, -1);
|
test.areEqual('slice.nextEventNumber', slice.nextEventNumber, Long.fromNumber(-1));
|
||||||
test.areEqual('slice.lastEventNumber', slice.lastEventNumber, streamSize-1);
|
test.areEqual('slice.lastEventNumber', slice.lastEventNumber, Long.fromNumber(streamSize-1));
|
||||||
test.areEqual('slice.isEndOfStream', slice.isEndOfStream, true);
|
test.areEqual('slice.isEndOfStream', slice.isEndOfStream, true);
|
||||||
for(var i = 0; i < streamSize; i++) {
|
for(var i = 0; i < streamSize; i++) {
|
||||||
var reverseIndex = streamSize - i - 1;
|
var reverseIndex = streamSize - i - 1;
|
||||||
test.eventEqualEventData('slice.events[' + i + ']', slice.events[i], self.eventsData[reverseIndex]);
|
test.eventEqualEventData('slice.events[' + i + ']', slice.events[i], self.eventsData[reverseIndex]);
|
||||||
test.areEqual('slice.events[' + i + '].originalEventNumber', slice.events[i].originalEventNumber, reverseIndex);
|
test.areEqual('slice.events[' + i + '].originalEventNumber', slice.events[i].originalEventNumber, Long.fromNumber(reverseIndex));
|
||||||
}
|
}
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -45,7 +46,7 @@ module.exports = {
|
||||||
.then(function(slice) {
|
.then(function(slice) {
|
||||||
test.areEqual('slice.status', slice.status, client.sliceReadStatus.StreamNotFound);
|
test.areEqual('slice.status', slice.status, client.sliceReadStatus.StreamNotFound);
|
||||||
test.areEqual('slice.stream', slice.stream, anotherStream);
|
test.areEqual('slice.stream', slice.stream, anotherStream);
|
||||||
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, streamSize-1);
|
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, Long.fromNumber(streamSize-1));
|
||||||
test.areEqual('slice.events.length', slice.events.length, 0);
|
test.areEqual('slice.events.length', slice.events.length, 0);
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -63,7 +64,7 @@ module.exports = {
|
||||||
.then(function(slice) {
|
.then(function(slice) {
|
||||||
test.areEqual('slice.status', slice.status, client.eventReadStatus.StreamDeleted);
|
test.areEqual('slice.status', slice.status, client.eventReadStatus.StreamDeleted);
|
||||||
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
||||||
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, streamSize-1);
|
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, Long.fromNumber(streamSize-1));
|
||||||
test.areEqual('slice.events.length', slice.events.length, 0);
|
test.areEqual('slice.events.length', slice.events.length, 0);
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -78,7 +79,7 @@ module.exports = {
|
||||||
.then(function(slice) {
|
.then(function(slice) {
|
||||||
test.areEqual('slice.status', slice.status, client.eventReadStatus.Success);
|
test.areEqual('slice.status', slice.status, client.eventReadStatus.Success);
|
||||||
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
||||||
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, streamSize*2);
|
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, Long.fromNumber(streamSize*2));
|
||||||
test.areEqual('slice.events.length', slice.events.length, 0);
|
test.areEqual('slice.events.length', slice.events.length, 0);
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var uuid = require('uuid');
|
var uuid = require('uuid');
|
||||||
var client = require('../src/client');
|
var client = require('../src/client');
|
||||||
|
var Long = require('long');
|
||||||
|
|
||||||
const streamSize = 100;
|
const streamSize = 100;
|
||||||
|
|
||||||
|
@ -22,10 +23,10 @@ module.exports = {
|
||||||
.then(function(slice) {
|
.then(function(slice) {
|
||||||
test.areEqual('slice.status', slice.status, client.eventReadStatus.Success);
|
test.areEqual('slice.status', slice.status, client.eventReadStatus.Success);
|
||||||
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
||||||
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, 0);
|
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, Long.fromNumber(0));
|
||||||
test.areEqual('slice.readDirection', slice.readDirection, 'forward');
|
test.areEqual('slice.readDirection', slice.readDirection, 'forward');
|
||||||
test.areEqual('slice.nextEventNumber', slice.nextEventNumber, streamSize);
|
test.areEqual('slice.nextEventNumber', slice.nextEventNumber, Long.fromNumber(streamSize));
|
||||||
test.areEqual('slice.lastEventNumber', slice.lastEventNumber, streamSize-1);
|
test.areEqual('slice.lastEventNumber', slice.lastEventNumber, Long.fromNumber(streamSize-1));
|
||||||
test.areEqual('slice.isEndOfStream', slice.isEndOfStream, true);
|
test.areEqual('slice.isEndOfStream', slice.isEndOfStream, true);
|
||||||
for(var i = 0; i < streamSize; i++) {
|
for(var i = 0; i < streamSize; i++) {
|
||||||
test.eventEqualEventData('slice.events[' + i + ']', slice.events[i], self.eventsData[i]);
|
test.eventEqualEventData('slice.events[' + i + ']', slice.events[i], self.eventsData[i]);
|
||||||
|
@ -44,7 +45,7 @@ module.exports = {
|
||||||
.then(function(slice) {
|
.then(function(slice) {
|
||||||
test.areEqual('slice.status', slice.status, client.sliceReadStatus.StreamNotFound);
|
test.areEqual('slice.status', slice.status, client.sliceReadStatus.StreamNotFound);
|
||||||
test.areEqual('slice.stream', slice.stream, anotherStream);
|
test.areEqual('slice.stream', slice.stream, anotherStream);
|
||||||
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, 0);
|
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, Long.fromNumber(0));
|
||||||
test.areEqual('slice.events.length', slice.events.length, 0);
|
test.areEqual('slice.events.length', slice.events.length, 0);
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -62,7 +63,7 @@ module.exports = {
|
||||||
.then(function(slice) {
|
.then(function(slice) {
|
||||||
test.areEqual('slice.status', slice.status, client.eventReadStatus.StreamDeleted);
|
test.areEqual('slice.status', slice.status, client.eventReadStatus.StreamDeleted);
|
||||||
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
||||||
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, 0);
|
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, Long.fromNumber(0));
|
||||||
test.areEqual('slice.events.length', slice.events.length, 0);
|
test.areEqual('slice.events.length', slice.events.length, 0);
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
@ -77,7 +78,7 @@ module.exports = {
|
||||||
.then(function(slice) {
|
.then(function(slice) {
|
||||||
test.areEqual('slice.status', slice.status, client.eventReadStatus.Success);
|
test.areEqual('slice.status', slice.status, client.eventReadStatus.Success);
|
||||||
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
test.areEqual('slice.stream', slice.stream, self.testStreamName);
|
||||||
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, streamSize*2);
|
test.areEqual('slice.fromEventNumber', slice.fromEventNumber, Long.fromNumber(streamSize*2));
|
||||||
test.areEqual('slice.events.length', slice.events.length, 0);
|
test.areEqual('slice.events.length', slice.events.length, 0);
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
|
|
|
@ -22,7 +22,7 @@ function delayOnlyFirst(count, action) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'Test Subscribe to Stream From Beginning (null)': function(test) {
|
'Test Subscribe to Stream From Beginning (null)': function(test) {
|
||||||
test.expect(36);
|
test.expect(32);
|
||||||
var self = this;
|
var self = this;
|
||||||
var liveProcessing = false;
|
var liveProcessing = false;
|
||||||
var catchUpEvents = [];
|
var catchUpEvents = [];
|
||||||
|
@ -57,15 +57,11 @@ module.exports = {
|
||||||
}
|
}
|
||||||
function subscriptionDropped(connection, reason, error) {
|
function subscriptionDropped(connection, reason, error) {
|
||||||
test.ok(liveEvents.length === 2, "Expecting 2 live event, got " + liveEvents.length);
|
test.ok(liveEvents.length === 2, "Expecting 2 live event, got " + liveEvents.length);
|
||||||
test.testLiveEvent('liveEvents[0]', liveEvents[0]);
|
test.testLiveEvent('liveEvents[0]', liveEvents[0], 2);
|
||||||
test.testLiveEvent('liveEvents[1]', liveEvents[1]);
|
test.testLiveEvent('liveEvents[1]', liveEvents[1], 3);
|
||||||
test.ok(liveEvents[0].originalEventNumber, 2);
|
|
||||||
test.ok(liveEvents[1].originalEventNumber, 3);
|
|
||||||
test.ok(catchUpEvents.length === 2, "Expecting 2 catchUp event, got " + catchUpEvents.length);
|
test.ok(catchUpEvents.length === 2, "Expecting 2 catchUp event, got " + catchUpEvents.length);
|
||||||
test.testReadEvent('catchUpEvents[0]', catchUpEvents[0]);
|
test.testReadEvent('catchUpEvents[0]', catchUpEvents[0], 0);
|
||||||
test.testReadEvent('catchUpEvents[1]', catchUpEvents[1]);
|
test.testReadEvent('catchUpEvents[1]', catchUpEvents[1], 1);
|
||||||
test.ok(liveEvents[0].originalEventNumber, 0);
|
|
||||||
test.ok(liveEvents[1].originalEventNumber, 1);
|
|
||||||
done(error);
|
done(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +78,7 @@ module.exports = {
|
||||||
.catch(test.done);
|
.catch(test.done);
|
||||||
},
|
},
|
||||||
'Test Subscribe to Stream From 0': function(test) {
|
'Test Subscribe to Stream From 0': function(test) {
|
||||||
test.expect(29);
|
test.expect(26);
|
||||||
var self = this;
|
var self = this;
|
||||||
var liveProcessing = false;
|
var liveProcessing = false;
|
||||||
var catchUpEvents = [];
|
var catchUpEvents = [];
|
||||||
|
@ -117,13 +113,10 @@ module.exports = {
|
||||||
}
|
}
|
||||||
function subscriptionDropped(connection, reason, error) {
|
function subscriptionDropped(connection, reason, error) {
|
||||||
test.ok(liveEvents.length === 2, "Expecting 2 live event, got " + liveEvents.length);
|
test.ok(liveEvents.length === 2, "Expecting 2 live event, got " + liveEvents.length);
|
||||||
test.testLiveEvent('liveEvents[0]', liveEvents[0]);
|
test.testLiveEvent('liveEvents[0]', liveEvents[0], 2);
|
||||||
test.testLiveEvent('liveEvents[1]', liveEvents[1]);
|
test.testLiveEvent('liveEvents[1]', liveEvents[1], 3);
|
||||||
test.ok(liveEvents[0].originalEventNumber, 2);
|
|
||||||
test.ok(liveEvents[1].originalEventNumber, 3);
|
|
||||||
test.ok(catchUpEvents.length === 1, "Expecting 1 catchUp event, got " + catchUpEvents.length);
|
test.ok(catchUpEvents.length === 1, "Expecting 1 catchUp event, got " + catchUpEvents.length);
|
||||||
test.testReadEvent('catchUpEvents[0]', catchUpEvents[0]);
|
test.testReadEvent('catchUpEvents[0]', catchUpEvents[0], 1);
|
||||||
test.ok(liveEvents[0].originalEventNumber, 1);
|
|
||||||
done(error);
|
done(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const uuid = require('uuid');
|
const uuid = require('uuid');
|
||||||
const client = require('../src/client');
|
const client = require('../src/client');
|
||||||
|
const Long = require('long');
|
||||||
|
|
||||||
function delay(ms) {
|
function delay(ms) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
@ -58,7 +59,7 @@ module.exports = {
|
||||||
.then(function(subscription) {
|
.then(function(subscription) {
|
||||||
test.areEqual("subscription.streamId", subscription.streamId, self.testStreamName);
|
test.areEqual("subscription.streamId", subscription.streamId, self.testStreamName);
|
||||||
test.areEqual("subscription.isSubscribedToAll", subscription.isSubscribedToAll, false);
|
test.areEqual("subscription.isSubscribedToAll", subscription.isSubscribedToAll, false);
|
||||||
test.areEqual("subscription.lastEventNumber", subscription.lastEventNumber, client.expectedVersion.emptyStream);
|
test.areEqual("subscription.lastEventNumber", subscription.lastEventNumber, Long.fromNumber(client.expectedVersion.emptyStream));
|
||||||
|
|
||||||
return self.conn.appendToStream(self.testStreamName, client.expectedVersion.emptyStream, publishedEvents);
|
return self.conn.appendToStream(self.testStreamName, client.expectedVersion.emptyStream, publishedEvents);
|
||||||
})
|
})
|
||||||
|
|
|
@ -111,7 +111,7 @@ module.exports = {
|
||||||
})
|
})
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
test.ok(result.logPosition, "Missing result.logPosition");
|
test.ok(result.logPosition, "Missing result.logPosition");
|
||||||
test.areEqual("result.nextExpectedVersion", result.nextExpectedVersion, self.events.length-1);
|
test.areEqual("result.nextExpectedVersion", result.nextExpectedVersion, Long.fromNumber(self.events.length-1));
|
||||||
test.done();
|
test.done();
|
||||||
})
|
})
|
||||||
.catch(test.done);
|
.catch(test.done);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user