forked from x-cubed/event-store-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue x-cubed#3 - Catch-up subscription - first green test
- Loading branch information
Zach Blocker
committed
Jun 10, 2016
1 parent
878bef6
commit 6580369
Showing
3 changed files
with
81 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var assert = require("assert"); | ||
|
||
var EventStoreClient = require("../index.js"); | ||
|
||
var dbconn = require("./common/dbconn"); | ||
var testData = require("./common/testData"); | ||
var defaultHostName = dbconn.defaultHostName; | ||
var credentials = dbconn.credentials; | ||
|
||
describe('Catch-Up Subscription', function() { | ||
var testStreams = []; | ||
|
||
context('setting up basic subscription', function () { | ||
it('should succeed', function (done) { | ||
dbconn.open(done, function (connection) { | ||
var actualEventNumbers = []; | ||
var streamName = testData.randomStreamName(); | ||
testStreams.push(streamName); | ||
|
||
var settings = new EventStoreClient.CatchUpSubscription.Settings(); | ||
|
||
testData.writeEvents( | ||
connection, credentials, streamName, 10, | ||
testData.fooEvent, | ||
function () { | ||
connection.subscribeToStreamFrom( | ||
streamName, 6, credentials, | ||
function (event) { | ||
actualEventNumbers.push(event.eventNumber); | ||
}, | ||
function () { | ||
assert.deepEqual(actualEventNumbers, [7, 8, 9]); | ||
done(); | ||
}, | ||
function () { | ||
assert.fail(null, null, 'Subscription dropped!'); | ||
done; | ||
}, | ||
settings); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
after(function () { | ||
dbconn.open(null, function (connection) { | ||
testData.deleteTestStreams(connection, credentials, testStreams); | ||
}); | ||
}); | ||
}); |