Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nano

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

36

cfg/tests.js

@@ -1,35 +0,1 @@

/* Config file used during tests
* Don't remove or modify
*
* - Or else...
* - Or else what?
* - Or else nothin'
*/
var cfg = { host: 'nodejsbug.iriscouch.com'
, port: '5984'
, ssl: false // Not yet
};
/* NOT REQUIRED */
cfg.http_credentials = function credentials() {
if (cfg.user && cfg.pass) {
return cfg.user + ":" + cfg.pass + "@";
}
else { return ""; }
}();
cfg.url_noauth = function (){
return "http" + (cfg.ssl ? "s" : "") + "://" + cfg.host + ":" + cfg.port;
}();
/* REQUIRED */
cfg.url = function (){
return "http" + (cfg.ssl ? "s" : "") + "://" + cfg.http_credentials + cfg.host +
":" + cfg.port;
}();
cfg.db_url = function (postfix) {
return cfg.url + '/' + postfix;
};
module.exports = exports = cfg;
module.exports = exports = cfg = { url: 'http://nodejsbug.iriscouch.com' };

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 0.8.1
* migrated tests to dscape/ensure
# 0.8.0

@@ -2,0 +6,0 @@

@@ -5,3 +5,3 @@ { "name": "nano"

, "repository": "git://github.com/dscape/nano"
, "version": "0.8.0"
, "version": "0.8.1"
, "author": "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)"

@@ -11,3 +11,3 @@ , "contributors": ["Thiago Arrais <thiago.arrais@gmail.com> (http://thiagoarrais.com)"]

, "dependencies": {"request": "~2.1.1", "underscore": "~1.1.7"}
, "devDependencies": { "async": "~0.1.9", "vows": "~0.5.10" }
, "devDependencies": { "async": "~0.1.9", "ensure": "~0.0.3" }
, "scripts": { "test": "./tests/run" }

@@ -14,0 +14,0 @@ , "main": "./nano.js"

@@ -1,6 +0,6 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, async = require('async')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
, nano = require('../../nano')(cfg)
, tests = exports;

@@ -10,6 +10,3 @@ function db_name(i) { return "att_de" + i; }

/*****************************************************************************
* att_des *
*****************************************************************************/
function att_des(callback) {
tests.att_des = function (callback) {
nano.db.create(db_name("a"), function () {

@@ -21,5 +18,5 @@ db("a").attachment.insert("new", "att", "Hello World!", "text/plain",

});
}
};
function att_des_ok(e,b) {
tests.att_des_ok = function (e,b) {
nano.db.destroy(db_name("a"));

@@ -29,8 +26,4 @@ assert.isNull(e);

assert.equal(b.id, "new");
}
};
vows.describe('attachment.destroy').addBatch({
"att_del": {
topic: function () { att_des(this.callback); }
, "=": att_des_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,5 +0,6 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, tests = exports
, pixel = "Qk06AAAAAAAAADYAAAAoAAAAAQAAAP////8BABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA==";

@@ -10,6 +11,3 @@

/*****************************************************************************
* att_get *
*****************************************************************************/
function att_get(callback) {
tests.att_get = function (callback) {
var buffer = new Buffer(pixel, 'base64');

@@ -27,5 +25,5 @@ nano.db.create(db_name("a"), function () {

});
}
};
function att_get_ok(e,b) {
tests.att_get_ok = function (e,b) {
assert.isNull(e);

@@ -35,8 +33,4 @@ nano.db.destroy(db_name("a"));

assert.equal(from_buffer, pixel);
}
};
vows.describe('attachment.get').addBatch({
"att_get": {
topic: function () { att_get(this.callback); }
, "=": att_get_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,6 +0,6 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, async = require('async')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
, nano = require('../../nano')(cfg)
, tests = exports;

@@ -10,12 +10,9 @@ function db_name(i) { return "att_in" + i; }

/*****************************************************************************
* att_new_doc *
*****************************************************************************/
function att_new_doc(callback) {
tests.att_new_doc = function (callback) {
nano.db.create(db_name("a"), function () {
db("a").attachment.insert("new", "att", "Hello World!", "text/plain", callback);
});
}
};
function att_new_doc_ok(e,b) {
tests.att_new_doc_ok = function (e,b) {
nano.db.destroy(db_name("a"));

@@ -25,8 +22,4 @@ assert.isNull(e);

assert.equal(b.id, "new");
}
};
vows.describe('attachment.insert').addBatch({
"att_new_doc": {
topic: function () { att_new_doc(this.callback); }
, "=": att_new_doc_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,2 +0,2 @@

var vows = require('vows')
var ensure = require('ensure')
, fs = require('fs')

@@ -6,2 +6,3 @@ , assert = require('assert')

, nano = require('../../nano')(cfg)
, tests = exports
, pixel = "Qk06AAAAAAAAADYAAAAoAAAAAQAAAP////8BABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA==";

@@ -14,6 +15,3 @@

/*****************************************************************************
* att_pipe *
*****************************************************************************/
function att_pipe(callback) {
tests.att_pipe = function (callback) {
var buffer = new Buffer(pixel, 'base64')

@@ -33,14 +31,10 @@ , file_stream = f_s("a");

});
}
};
function att_pipe_ok() {
tests.att_pipe_ok = function () {
nano.db.destroy(db_name("a"));
assert.equal(fs.readFileSync(file_name("a")).toString("base64"), pixel);
//fs.deleteFileSync(file_name("a"));
}
fs.unlinkSync(file_name("a"));
};
vows.describe('attachment.pipe').addBatch({
"att_pipe": {
topic: function () { att_pipe(this.callback); }
, "=": att_pipe_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,6 +0,6 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, async = require('async')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
, nano = require('../../nano')(cfg)
, tests = exports;

@@ -10,6 +10,3 @@ function db_name(i) { return "att_up" + i; }

/*****************************************************************************
* att_doc *
*****************************************************************************/
function att_doc(callback) {
tests.att_doc = function (callback) {
var pixel = "Qk06AAAAAAAAADYAAAAoAAAAAQAAAP////8BABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA=="

@@ -25,5 +22,5 @@ , buffer = new Buffer(pixel, 'base64');

});
}
};
function att_doc_ok(e,b) {
tests.att_doc_ok = function (e,b) {
nano.db.destroy(db_name("b"));

@@ -33,8 +30,4 @@ assert.isNull(e);

assert.equal(b.id, "new");
}
};
vows.describe('attachment.update').addBatch({
"att_doc": {
topic: function () { att_doc(this.callback); }
, "=": att_doc_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,6 +0,7 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, async = require('async')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
, nano = require('../../nano')(cfg)
, tests = exports;

@@ -10,6 +11,3 @@ function db_name(i) { return "doc_ch" + i; }

/*****************************************************************************
* changes_db *
*****************************************************************************/
function changes_db(callback) {
tests.changes_db = function (callback) {
nano.db.create(db_name("a"), function () {

@@ -25,5 +23,5 @@ async.parallel(

});
}
};
function changes_db_ok(e,b) {
tests.changes_db_ok = function (e,b) {
nano.db.destroy(db_name("a"));

@@ -33,9 +31,4 @@ assert.isNull(e);

assert.equal(b.last_seq,3);
}
};
vows.describe('nano.db.changes').addBatch({
"changes_db": {
topic: function () { changes_db(this.callback); }
, "=": changes_db_ok
}
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,11 +0,9 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, async = require('async')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
, nano = require('../../nano')(cfg)
, tests = exports;
/*****************************************************************************
* compact_db *
*****************************************************************************/
function compact_db(callback) {
tests.compact_db = function (callback) {
nano.db.create("db_co1", function () {

@@ -25,5 +23,5 @@ var db = nano.use("db_co1");

});
}
};
function compact_db_ok(err,list) {
tests.compact_db_ok = function (err,list) {
nano.db.destroy("db_co1");

@@ -33,9 +31,4 @@ assert.isNull(err);

assert.equal(list.doc_del_count, 0);
}
};
vows.describe('nano.db.compact').addBatch({
"compact_db": {
topic: function () { compact_db(this.callback); }
, "=": compact_db_ok
}
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,50 +0,40 @@

var vows = require('vows')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, tests = exports;
/*****************************************************************************
* create_db *
*****************************************************************************/
function create_db (callback) {
tests.create_db = function (callback) {
nano.db.destroy("db_cr1", function () {
nano.db.create("db_cr1", callback);
});
}
};
function create_db_ok(e,b) {
tests.create_db_ok = function (e,b) {
nano.db.destroy("db_cr1");
assert.isNull(e);
assert.equal(b.ok, true);
}
};
/*****************************************************************************
* recursive_retries_create_db *
*****************************************************************************/
function recursive_retries_create_db(tried,callback) {
tests.recursive_create_db = function (tried,callback) {
if(typeof tried === 'function') {
callback = tried;
tried = {tried:0, max_retries:5};
}
nano.db.destroy("db_cr2", function () {
nano.db.create("db_cr2", function () {
if(tried.tried === tried.max_retries) {
callback(true);
}
if(tried.tried === tried.max_retries) { callback(null,true); }
else {
tried.tried += 1;
recursive_retries_create_db(tried,callback);
tests.recursive_create_db(tried,callback);
}
});
});
}
};
function recursive_retries_create_db_ok(v) {
tests.recursive_create_db_ok = function (_,v) {
nano.db.destroy("db_cr2");
assert.equal(v,true);
}
};
vows.describe('nano.db.create').addBatch({
"create_db": {
topic: function () { create_db(this.callback); }
, "=": create_db_ok },
"recursive_retries_create_db": {
topic: function () { recursive_retries_create_db({tried:0, max_retries:5},this.callback); }
, "=": recursive_retries_create_db_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,26 +0,19 @@

var vows = require('vows')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, tests = exports;
/*****************************************************************************
* destroy_db *
*****************************************************************************/
function destroy_db(callback) {
tests.destroy_db = function (callback) {
nano.db.create("db_de1", function () {
nano.db.destroy("db_de1", callback);
});
}
};
function destroy_db_ok(e,b) {
tests.destroy_db_ok = function (e,b) {
nano.db.destroy("db_de1");
assert.isNull(e);
assert.equal(b.ok, true);
}
};
vows.describe('nano.db.destroy').addBatch({
"destroy_db": {
topic: function () { destroy_db(this.callback); }
, "=": destroy_db_ok
}
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,10 +0,8 @@

var vows = require('vows')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, tests = exports;
/*****************************************************************************
* get_db *
*****************************************************************************/
function get_db(callback) {
tests.get_db = function (callback) {
nano.db.create("db_ge1", function () {

@@ -16,5 +14,5 @@ nano.db.get("db_ge1", function (e,b) {

});
}
};
function get_db_ok(e,b) {
tests.get_db_ok = function (e,b) {
nano.db.destroy("db_ge1");

@@ -25,9 +23,4 @@ assert.isNull(e);

assert.equal(b.db_name,"db_ge1");
}
};
vows.describe('nano.db.get').addBatch({
"get_db": {
topic: function () { get_db(this.callback); }
, "=": get_db_ok
}
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,26 +0,17 @@

var vows = require('vows')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, tests = exports;
/*****************************************************************************
* list_db *
*****************************************************************************/
function list_db(callback) {
tests.list_db = function (callback) {
nano.db.create("db_li1", function () {
nano.db.list(callback);
});
}
};
function list_db_ok(e,b) {
tests.list_db_ok = function (e,b) {
nano.db.destroy("db_li1");
assert.isNull(e);
assert.notEqual(b.indexOf("db_li1"),-1);
}
vows.describe('nano.db.list').addBatch({
"list_db": {
topic: function () { list_db(this.callback); }
, "=": list_db_ok
}
}).exportTo(module);
};

@@ -1,11 +0,9 @@

var vows = require('vows')
, assert = require('assert')
, async = require('async')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
var ensure = require('ensure')
, assert = require('assert')
, async = require('async')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, tests = exports;
/*****************************************************************************
* replicate_db *
*****************************************************************************/
function replicate_db(callback) {
tests.replicate_db = function (callback) {
nano.db.create("db_re1", function () {

@@ -26,5 +24,5 @@ var db = nano.use("db_re1")

});
}
};
function replicate_db_ok(e,b) {
tests.replicate_db_ok = function (e,b) {
nano.db.destroy("db_re1");

@@ -35,9 +33,4 @@ nano.db.destroy("db_re1_replica");

assert.ok(b.rows);
}
};
vows.describe('nano.db.replicate').addBatch({
"replicate_db": {
topic: function () { replicate_db(this.callback); }
, "=": replicate_db_ok
}
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,6 +0,7 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, async = require('async')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
, nano = require('../../nano')(cfg)
, tests = exports;

@@ -10,6 +11,3 @@ function db_name(i) { return "doc_bu" + i; }

/*****************************************************************************
* bulks_docs *
*****************************************************************************/
function bulk_docs(callback) {
tests.bulk_docs = function (callback) {
nano.db.create(db_name("a"), function () {

@@ -22,5 +20,5 @@ db("a").bulk(

});
}
};
function bulk_docs_ok(e,b) {
tests.bulk_docs_ok = function (e,b) {
nano.db.destroy(db_name("a"));

@@ -31,8 +29,4 @@ assert.isNull(e);

assert.ok(b[1].id);
}
};
vows.describe('doc.bulk').addBatch({
"bulk_doc": {
topic: function () { bulk_docs(this.callback); }
, "=": bulk_docs_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,13 +0,10 @@

var vows = require('vows')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, db_name = "doc_de1"
, db = nano.use(db_name);
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, tests = exports;
/*****************************************************************************
* destroy_doc *
*****************************************************************************/
function destroy_doc(callback) {
nano.db.create(db_name, function () {
tests.destroy_doc = function (callback) {
var db = nano.use("doc_de1");
nano.db.create("doc_de1", function () {
db.insert({foo: "bar"}, "foo", function (_,b) {

@@ -20,6 +17,6 @@ db.destroy("foo", b.rev, function (e,b) {

});
}
};
function destroy_doc_ok(e,b) {
nano.db.destroy(db_name);
tests.destroy_doc_ok = function (e,b) {
nano.db.destroy("doc_de1");
assert.isNull(e);

@@ -29,9 +26,4 @@ assert.ok(b.ok);

assert.ok(b.rev);
}
};
vows.describe('db.destroy').addBatch({
"destroy_doc": {
topic: function () { destroy_doc(this.callback); }
, "=": destroy_doc_ok
}
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,23 +0,20 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, db_name = "doc_ge1"
, db2_name = "doc_ge2"
, db = nano.use(db_name)
, db2 = nano.use(db2_name);
, tests = exports;
/*****************************************************************************
* get_doc *
*****************************************************************************/
function get_doc(callback) {
nano.db.create(db_name, function () {
db.insert({foo: "bar"}, "foo", function () {
db.get("foo", callback);
function db_name(i) { return "doc_ge" + i; }
function db(i) { return nano.use(db_name(i)); }
tests.get_doc = function (callback) {
nano.db.create(db_name('a'), function () {
db('a').insert({foo: "bar"}, "foo", function () {
db('a').get("foo", callback);
});
});
}
};
function get_doc_ok(e,b) {
nano.db.destroy(db_name);
tests.get_doc_ok = function (e,b) {
nano.db.destroy(db_name('a'));
assert.isNull(e);

@@ -27,19 +24,16 @@ assert.ok(b._rev);

assert.equal(b.foo, "bar");
}
};
/*****************************************************************************
* get_doc_params *
*****************************************************************************/
function get_doc_params(callback) {
nano.db.create(db2_name, function () {
db2.insert({foo: "bar"}, "foo", function () {
db2.insert({foo: "bar"}, "foo", function () { // Conflict, no rev
db2.get("foo", {revs_info: true}, callback);
tests.get_doc_params = function (callback) {
nano.db.create(db_name('b'), function () {
db('b').insert({foo: "bar"}, "foo", function () {
db('b').insert({foo: "bar"}, "foo", function () { // Conflict, no rev
db('b').get("foo", {revs_info: true}, callback);
});
});
});
}
};
function get_doc_params_ok(e,b) {
nano.db.destroy(db2_name);
tests.get_doc_params_ok = function (e,b) {
nano.db.destroy(db_name('b'));
assert.isNull(e);

@@ -49,11 +43,4 @@ assert.ok(b._revs_info);

assert.equal(b.foo, "bar");
}
};
vows.describe('db.get').addBatch({
"get_doc": {
topic: function () { get_doc(this.callback); }
, "=": get_doc_ok },
"get_doc_params": {
topic: function () { get_doc_params(this.callback); }
, "=": get_doc_params_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,5 +0,6 @@

var vows = require('vows')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg);
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, tests = exports;

@@ -9,12 +10,9 @@ function db_name(i) { return "doc_in" + i; }

/*****************************************************************************
* insert_doc *
*****************************************************************************/
function insert_doc(callback) {
tests.insert_doc = function (callback) {
nano.db.create(db_name("a"), function () {
db("a").insert({foo: "bar"}, callback);
});
}
};
function insert_doc_ok(e,b) {
tests.insert_doc_ok = function (e,b) {
nano.db.destroy(db_name("a"));

@@ -25,8 +23,5 @@ assert.isNull(e);

assert.ok(b.id);
}
};
/*****************************************************************************
* insert_doc_path *
*****************************************************************************/
function insert_doc_path(callback) {
tests.insert_doc_path = function (callback) {
nano.db.create(db_name("b"), function () {

@@ -37,3 +32,3 @@ db("b").insert({foo: "bar"}, 'some/path', callback);

function insert_doc_path_ok(e,b) {
tests.insert_doc_path_ok = function (e,b) {
nano.db.destroy(db_name("b"));

@@ -46,9 +41,2 @@ assert.isNull(e);

vows.describe('db.insert').addBatch({
"insert_doc": {
topic: function () { insert_doc(this.callback); }
, "=": insert_doc_ok },
"insert_doc_path": {
topic: function () { insert_doc_path(this.callback); }
, "=": insert_doc_path_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,2 +0,2 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')

@@ -6,44 +6,36 @@ , async = require('async')

, nano = require('../../nano')(cfg)
, db_name = "doc_li1"
, db2_name = "doc_li2"
, db3_name = "doc_li3"
, db = nano.use(db_name)
, db2 = nano.use(db2_name)
, db3 = nano.use(db3_name);
, tests = exports;
/*****************************************************************************
* list_doc *
*****************************************************************************/
function list_doc(callback) {
nano.db.create(db_name, function () {
function db_name(i) { return "doc_li" + i; }
function db(i) { return nano.use(db_name(i)); }
tests.list_doc = function (callback) {
nano.db.create(db_name('a'), function () {
async.parallel(
[ function(cb) { db.insert({"foo": "bar"}, "foobar", cb); }
, function(cb) { db.insert({"bar": "foo"}, "barfoo", cb); }
, function(cb) { db.insert({"foo": "baz"}, "foobaz", cb); }
[ function(cb) { db('a').insert({"foo": "bar"}, "foobar", cb); }
, function(cb) { db('a').insert({"bar": "foo"}, "barfoo", cb); }
, function(cb) { db('a').insert({"foo": "baz"}, "foobaz", cb); }
],
function(err, results){
db.list(callback);
db('a').list(callback);
});
});
}
};
function list_doc_ok(e,b) {
nano.db.destroy(db_name);
tests.list_doc_ok = function (e,b) {
nano.db.destroy(db_name('a'));
assert.isNull(e);
assert.equal(b.total_rows,3);
assert.ok(b.rows);
}
};
/*****************************************************************************
* ns_list_doc *
*****************************************************************************/
function ns_list_doc(callback) {
nano.db.create(db2_name, function () {
tests.ns_list_doc = function (callback) {
nano.db.create(db_name('b'), function () {
async.parallel(
[ function(cb) { db2.insert({"foo": "bar"}, "foobar", cb); }
, function(cb) { db2.insert({"bar": "foo"}, "barfoo", cb); }
, function(cb) { db2.insert({"foo": "baz"}, "foobaz", cb); }
[ function(cb) { db('b').insert({"foo": "bar"}, "foobar", cb); }
, function(cb) { db('b').insert({"bar": "foo"}, "barfoo", cb); }
, function(cb) { db('b').insert({"foo": "baz"}, "foobaz", cb); }
],
function(err, results){
nano.request( { db: db2_name
nano.request( { db: db_name('b')
, doc: "_all_docs"

@@ -55,6 +47,6 @@ , method: "GET"

});
}
};
function ns_list_doc_ok(e,b) {
nano.db.destroy(db2_name);
tests.ns_list_doc_ok = function (e,b) {
nano.db.destroy(db_name('b'));
assert.isNull(e);

@@ -64,22 +56,19 @@ assert.equal(b.rows.length,1);

assert.ok(b.rows);
}
};
/*****************************************************************************
* list_doc_params *
*****************************************************************************/
function list_doc_params(callback) {
nano.db.create(db3_name, function () {
tests.list_doc_params = function (callback) {
nano.db.create(db_name('c'), function () {
async.parallel(
[ function(cb) { db3.insert({"foo": "bar"}, "foobar", cb); }
, function(cb) { db3.insert({"bar": "foo"}, "barfoo", cb); }
, function(cb) { db3.insert({"foo": "baz"}, "foobaz", cb); }
[ function(cb) { db('c').insert({"foo": "bar"}, "foobar", cb); }
, function(cb) { db('c').insert({"bar": "foo"}, "barfoo", cb); }
, function(cb) { db('c').insert({"foo": "baz"}, "foobaz", cb); }
],
function(err, results){
db3.list({startkey: '"c"'},callback);
db('c').list({startkey: '"c"'},callback);
});
});
}
};
function list_doc_params_ok(e,b) {
nano.db.destroy(db3_name);
tests.list_doc_params_ok = function (e,b) {
nano.db.destroy(db_name('c'));
assert.isNull(e);

@@ -89,16 +78,4 @@ assert.equal(b.rows.length,2);

assert.ok(b.rows);
}
};
vows.describe('doc.list').addBatch({
"list_doc": {
topic: function () { list_doc(this.callback); }
, "=": list_doc_ok },
"ns_list_doc": {
topic: function () { ns_list_doc(this.callback); }
, "=": ns_list_doc_ok },
"list_doc_params": {
topic: function () { list_doc_params(this.callback); }
, "=": list_doc_params_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,21 +0,20 @@

var vows = require('vows')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, db_name = "doc_up1"
, db = nano.use(db_name);
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')(cfg)
, tests = exports;
/*****************************************************************************
* update_doc *
*****************************************************************************/
function update_doc(callback) {
nano.db.create(db_name, function () {
db.insert({foo: "bar"}, "foo", function (_,b) {
db.insert({"_rev": b.rev, foo: "baz"}, "foo", callback);
function db_name(i) { return "doc_up" + i; }
function db(i) { return nano.use(db_name(i)); }
tests.update_doc = function (callback) {
nano.db.create(db_name('a'), function () {
db('a').insert({foo: "bar"}, "foo", function (_,b) {
db('a').insert({"_rev": b.rev, foo: "baz"}, "foo", callback);
});
});
}
};
function update_doc_ok(e,b) {
nano.db.destroy(db_name);
tests.update_doc_ok = function (e,b) {
nano.db.destroy(db_name('a'));
assert.isNull(e);

@@ -25,9 +24,4 @@ assert.equal(b.id, "foo");

assert.ok(b.rev);
}
};
vows.describe('db.update').addBatch({
"update_doc": {
topic: function () { update_doc(this.callback); }
, "=": update_doc_ok
}
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,140 +0,56 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano');
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')
, tests = exports;
/*****************************************************************************
* url *
*****************************************************************************/
function url(callback) { callback(null,nano('http://someurl.com')); }
function url_ok(_,n) { assert.equal(n.config.url, "http://someurl.com"); }
tests.url = function (callback) { callback(null,nano('http://someurl.com')); };
tests.url_ok = function (_,n) { assert.equal(n.config.url, "http://someurl.com"); };
/*****************************************************************************
* url2 *
*****************************************************************************/
function url2(callback) { callback(null,nano('http://someurl.com/')); }
function url2_ok(_,n) { assert.equal(n.config.url, "http://someurl.com/"); }
tests.url2 = function (callback) { callback(null,nano('http://someurl.com/')); };
tests.url2_ok = function (_,n) { assert.equal(n.config.url, "http://someurl.com/"); };
/*****************************************************************************
* url_db *
*****************************************************************************/
function url_db(callback) {
nano(cfg.db_url("adb")).info(callback);
}
function url_db_ok(e,b) {
tests.url_db = function (callback) { nano(cfg.url + "/adb").info(callback); };
tests.url_db_ok = function (e,b) {
assert.equal(e.message,"no_db_file");
assert.equal(e.error, "not_found");
assert.equal(e.request.uri, (cfg.url + '/adb'));
}
};
/*****************************************************************************
* url_db2 *
*****************************************************************************/
function url_db2(callback) {
nano(cfg.db_url("adb/")).info(callback);
}
function url_db2_ok(e,b) {
tests.url_db2 = function (callback) { nano(cfg.url + "/acb/").info(callback); };
tests.url_db2_ok = function (e,b) {
assert.equal(e.message,"no_db_file");
assert.equal(e.error, "not_found");
assert.equal(e.request.uri, (cfg.url + '/adb'));
}
assert.equal(e.request.uri, (cfg.url + '/acb'));
};
/*****************************************************************************
* url_db3 *
*****************************************************************************/
function url_db3(callback) {
nano(cfg.db_url("adb/blergh")).info(callback);
}
function url_db3_ok(e,b) {
tests.url_db3 = function (callback) { nano(cfg.url + "/adb/blergh").info(callback); };
tests.url_db3_ok = function (e,b) {
assert.equal(e.message,"no_db_file");
assert.equal(e.error, "not_found");
assert.equal(e.request.uri, (cfg.url + '/adb'));
}
};
/*****************************************************************************
* url_db4 *
*****************************************************************************/
function url_db4(callback) {
nano(cfg.db_url("a/b/d/c/")).info(callback);
}
function url_db4_ok(e,b) {
tests.url_db4 = function (callback) { nano(cfg.url + "/a/b/d/c/").info(callback); };
tests.url_db4_ok = function (e,b) {
assert.equal(e.message,"no_db_file");
assert.equal(e.error, "not_found");
assert.equal(e.request.uri, (cfg.url + '/a'));
}
};
/*****************************************************************************
* file *
*****************************************************************************/
function file(callback) { callback(null,nano(__dirname+ '/../../cfg/tests.js')); }
function file_ok(_,n) { assert.equal(n.config.url, cfg.url); }
tests.file = function (callback) { callback(null,nano(__dirname+ '/../../cfg/tests.js')); };
tests.file_ok = function (_,n) { assert.equal(n.config.url, cfg.url); };
/*****************************************************************************
* bad_file *
*****************************************************************************/
function bad_file(callback) {
callback(null,nano('notafile'));
}
function bad_file_ok(_,e) { assert.equal(e.config.url,"http://localhost:5984"); }
tests.bad_file = function (callback) { callback(null,nano('notafile')); };
tests.bad_file_ok = function (_,e) { assert.equal(e.config.url,"http://localhost:5984"); };
/*****************************************************************************
* object *
*****************************************************************************/
function object(callback) { callback(null,nano(cfg)); }
function object_ok(_,n) { assert.equal(n.config.url, cfg.url); }
tests.obj_cfg = function (callback) { callback(null,nano(cfg)); };
tests.obj_cfg_ok = function (_,n) { assert.equal(n.config.url, cfg.url); };
/*****************************************************************************
* not_string_or_object *
*****************************************************************************/
function not_string_or_object(callback) {
callback(null,nano(false));
}
function not_string_or_object_ok(_,e) {
assert.equal(e.config.url,"http://localhost:5984");
}
tests.not_string_or_object = function (callback) { callback(null,nano(false)); };
tests.not_string_or_object_ok = function (_,e) { assert.equal(e.config.url,"http://localhost:5984"); };
/*****************************************************************************
* nano_undefined *
*****************************************************************************/
function nano_undefined(callback) {
callback(null,nano());
}
function nano_undefined_ok(_,e) {
assert.equal(e.config.url,"http://localhost:5984");
}
tests.nano_undefined = function (callback) { callback(null,nano()); };
tests.nano_undefined_ok = function (_,e) { assert.equal(e.config.url,"http://localhost:5984"); };
vows.describe('config').addBatch({
"url": {
topic: function () { url(this.callback); }
, "=": url_ok },
"url2": {
topic: function () { url2(this.callback); }
, "=": url2_ok },
"url_db": {
topic: function () { url_db(this.callback); }
, "=": url_db_ok },
"url_db2": {
topic: function () { url_db2(this.callback); }
, "=": url_db2_ok },
"url_db3": {
topic: function () { url_db3(this.callback); }
, "=": url_db3_ok },
"url_db4": {
topic: function () { url_db4(this.callback); }
, "=": url_db4_ok },
"file": {
topic: function () { file(this.callback); }
, "=": file_ok },
"bad_file": {
topic: function () { bad_file(this.callback); }
, "=": bad_file_ok },
"object": {
topic: function () { object(this.callback); }
, "=": object_ok },
"nano_undefined": {
topic: function () { nano_undefined(this.callback); }
, "=": nano_undefined_ok },
"not_string_or_object": {
topic: function () { not_string_or_object(this.callback); }
, "=": not_string_or_object_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,13 +0,11 @@

var vows = require('vows')
var ensure = require('ensure')
, assert = require('assert')
, err = require('../../error');
, err = require('../../error')
, tests = exports;
/*****************************************************************************
* empty_error *
*****************************************************************************/
function empty_error(callback) {
tests.empty_error = function (callback) {
callback(null,err.couch(null,null,null,null));
}
};
function empty_error_ok(_,e) {
tests.empty_error_ok = function (_,e) {
assert.equal(e.message, "Unknown Error");

@@ -17,12 +15,9 @@ assert.equal(e.status_code, 500);

assert.ok(typeof e.request === 'object');
}
};
/*****************************************************************************
* error_412 *
*****************************************************************************/
function error_412(callback) {
tests.error_412 = function (callback) {
callback(null,err.couch(null,null,null,412));
}
};
function error_412_ok(_,e) {
tests.error_412_ok = function (_,e) {
assert.equal(e.message, "Precondition Failed");

@@ -32,11 +27,4 @@ assert.equal(e.status_code, 412);

assert.ok(typeof e.request === 'object');
}
};
vows.describe('error').addBatch({
"empty_error": {
topic: function () { empty_error(this.callback); }
, "=": empty_error_ok },
"error_412": {
topic: function () { error_412(this.callback); }
, "=": error_412_ok }
}).exportTo(module);
ensure(__filename, tests, module);

@@ -1,25 +0,12 @@

var vows = require('vows')
, assert = require('assert')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano');
var ensure = require('ensure')
, assert = require('assert')
, nano = require('../../nano')
, tests = exports;
/*****************************************************************************
* version *
*****************************************************************************/
function version(callback) { callback(null,nano.version); }
function version_ok(_,n) { assert.ok(n); }
tests.version = function (callback) { callback(null,nano.version); };
tests.version_ok = function (_,n) { assert.ok(n); };
/*****************************************************************************
* path *
*****************************************************************************/
function path(callback) { callback(null,nano.path); }
function path_ok(_,n) { assert.ok(n); }
tests.path = function (callback) { callback(null,nano.path); };
tests.path_ok = function (_,n) { assert.ok(n); };
vows.describe('nano').addBatch({
"version": {
topic: function () { version(this.callback); }
, "=": version_ok },
"path": {
topic: function () { path(this.callback); }
, "=": path_ok }
}).exportTo(module);
ensure(__filename, tests, module);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc