[Pkg-javascript-commits] [node-leveldown] 32/492: extra tests for non-existant start position

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:13:42 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.

commit 896ce84bc7014256295260fd7d1113a38ad1150e
Author: Rod Vagg <rod at vagg.org>
Date:   Thu Aug 30 15:28:42 2012 +1000

    extra tests for non-existant start position
---
 test/read-stream-test.js | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/test/read-stream-test.js b/test/read-stream-test.js
index 10580d5..2a6769e 100644
--- a/test/read-stream-test.js
+++ b/test/read-stream-test.js
@@ -192,6 +192,47 @@ buster.testCase('ReadStream', {
       }.bind(this))
     }
 
+  , 'test readStream() with "start" being mid-way key (float)': function (done) {
+      this.openTestDatabase(function (db) {
+        db.batch(this.sourceData.slice(), function (err) {
+          refute(err)
+
+          // '49.5' doesn't actually exist but we expect it to start at '50' because '49' < '49.5' < '50' (in string terms as well as numeric)
+          var rs = db.readStream({ start: '49.5' })
+          assert.isFalse(rs.writable)
+          assert.isTrue(rs.readable)
+          rs.on('ready', this.readySpy)
+          rs.on('data' , this.dataSpy)
+          rs.on('end'  , this.endSpy)
+          rs.on('close', this.verify.bind(this, rs, done))
+
+          // slice off the first 50 so verify() expects only the last 50 even though all 100 are in the db
+          this.sourceData = this.sourceData.slice(50)
+        }.bind(this))
+      }.bind(this))
+    }
+
+  , 'test readStream() with "start" being mid-way key (string)': function (done) {
+      this.openTestDatabase(function (db) {
+        db.batch(this.sourceData.slice(), function (err) {
+          refute(err)
+
+          // '499999' doesn't actually exist but we expect it to start at '50' because '49' < '499999' < '50' (in string terms)
+          // the same as the previous test but we're relying solely on string ordering
+          var rs = db.readStream({ start: '499999' })
+          assert.isFalse(rs.writable)
+          assert.isTrue(rs.readable)
+          rs.on('ready', this.readySpy)
+          rs.on('data' , this.dataSpy)
+          rs.on('end'  , this.endSpy)
+          rs.on('close', this.verify.bind(this, rs, done))
+
+          // slice off the first 50 so verify() expects only the last 50 even though all 100 are in the db
+          this.sourceData = this.sourceData.slice(50)
+        }.bind(this))
+      }.bind(this))
+    }
+
   , 'test readStream() with "end"': function (done) {
       this.openTestDatabase(function (db) {
         db.batch(this.sourceData.slice(), function (err) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git



More information about the Pkg-javascript-commits mailing list