Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added tests for doc.list

  • Loading branch information...
commit 37d1454eb318f4767a98e050dee0d563984f4d33 1 parent a7c4175
@dscape authored
Showing with 40 additions and 1 deletion.
  1. +2 −0  .gitignore
  2. +3 −1 nano.js
  3. +1 −0  package.json
  4. +34 −0 tests/doc/list.js
View
2  .gitignore
@@ -0,0 +1,2 @@
+.DS_Store
+node_modules
View
4 nano.js
@@ -233,9 +233,11 @@ module.exports = exports = nano = function database_module(cfg) {
, get: get_db
, destroy: destroy_db
, list: list_dbs
- , use: document_module
+ , use: document_module // Alias
+ , scope: document_module // Alias
}
, use: document_module
+ , scope: document_module // Alias
, request: request_db
};
return public_functions;
View
1  package.json
@@ -5,6 +5,7 @@
, "author": "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)"
, "keywords": ["CouchDB", "data", "request", "json", "nosql", "micro", "nano"]
, "dependencies": { "request": ">=1.9.8", "b64": "1.0.0" }
+, "devDependencies": { "async": "~0.1.9", "vows": "~0.5.10" }
, "main": "./nano.js"
, "engines" : { "node" : "~v0.4.8" }
}
View
34 tests/doc/list.js
@@ -0,0 +1,34 @@
+var vows = require('/usr/lib/node_modules/vows/lib/vows')
+ , assert = require('assert')
+ , async = require('async')
+ , cfg = require('../../cfg/tests.js')
+ , nano = require('../../nano')(cfg)
+ , db_name = "doc_li1"
+ , db = nano.use(db_name);
+
+function list_doc(callback) {
+ nano.db.create(db_name, function () {
+ async.parallel(
+ [ function(cb) { db.insert("foobar", {"foo": "bar"}, cb); }
+ , function(cb) { db.insert("barfoo", {"bar": "foo"}, cb); }
+ , function(cb) { db.insert("foobaz", {"foo": "baz"}, cb); }
+ ],
+ function(err, results){
+ db.list(callback);
+ });
+ });
+}
+
+function list_doc_ok(e,h,b) {
+ assert.isNull(e);
+ assert.equal(b.total_rows,3);
+ assert.ok(b.rows);
+ nano.db.destroy(db_name);
+}
+
+vows.describe('doc.list').addBatch({
+ "list_doc": {
+ topic: function () { list_doc(this.callback); }
+ , "=": list_doc_ok
+ }
+}).exportTo(module);
Please sign in to comment.
Something went wrong with that request. Please try again.