Comparing version 0.9.8 to 1.0.0
@@ -266,3 +266,3 @@ /* minimal couch in node | ||
} | ||
return relax({db: db_name, path: ("_compact" + design_name), method: "POST"},callback); | ||
return relax({db: db_name, doc: "_compact", att: design_name, method: "POST"},callback); | ||
} | ||
@@ -269,0 +269,0 @@ |
@@ -5,5 +5,5 @@ { "name" : "nano" | ||
, "repository" : "git://github.com/dscape/nano" | ||
, "version" : "0.9.8" | ||
, "version" : "1.0.0" | ||
, "author" : "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)" | ||
, "contributors" : | ||
, "contributors" : | ||
[ "Thiago Arrais <thiago.arrais@gmail.com> (http://thiagoarrais.com)" | ||
@@ -13,7 +13,8 @@ , "Derek Perez <derek@derekperez.com> (http://blog.derekperez.com)" | ||
, "Artur Konarski (http://tarantoga.com)" | ||
, "Pedro Teixeira <pedro.teixeira@gmail.com (http://metaduck.com)" | ||
, "Pedro Teixeira <pedro.teixeira@gmail.com> (http://metaduck.com)" | ||
] | ||
, "keywords" : ["couchdb", "data", "request", "json", "nosql", "micro", "nano"] | ||
, "dependencies" : {"request": "2.2.9", "underscore": "~1.1.7"} | ||
, "devDependencies" : { "async": "~0.1.9", "ensure": "0.4.6" } | ||
, "keywords" : | ||
["couchdb", "data", "request", "json", "nosql", "micro", "nano", "database"] | ||
, "dependencies" : {"request": "2.2.0", "underscore": "~1.1.7"} | ||
, "devDependencies" : { "async": "~0.1.9", "ensure": "0.4.6", "nock": "0.5.x"} | ||
, "scripts" : { "test": "./node_modules/ensure/bin/tap.js tests/*/*.js" } | ||
@@ -20,0 +21,0 @@ , "main" : "./nano.js" |
@@ -202,2 +202,3 @@ # nano | ||
* bugs: <http://github.com/dscape/nano/issues> | ||
* build: [![build status](https://secure.travis-ci.org/dscape/nano.png)](http://travis-ci.org/dscape/nano) | ||
@@ -204,0 +205,0 @@ `(oO)--',-` in [caos][3] |
@@ -6,3 +6,39 @@ var ensure = require('ensure') | ||
, tests = exports | ||
, nock = require('nock') | ||
, couchdb | ||
; | ||
path = '/' + db_name("a"); | ||
location = cfg.url + path; | ||
couchdb = nock(cfg.url) | ||
.put('/' + db_name("a") | ||
, '' | ||
, { 'content-type': 'application/json' | ||
, "accept": 'application/json' }) | ||
.reply(201, { ok: true }, | ||
{ location: cfg.url + '/' + db_name("a") | ||
, date: 'Wed, 30 Nov 2011 15:21:58 GMT' | ||
, 'content-type': 'application/json' | ||
, 'cache-control': 'must-revalidate' | ||
, 'status-code': 201 | ||
}) | ||
.put(path + '/new/att', "\"Hello World!\"") | ||
.reply(201, { ok: true, id: 'new', rev: '1-921bd51ccdef5ab4c84b07bab7b80e7e' }, | ||
{ location: location + '/new/att' | ||
, date: 'Wed, 30 Nov 2011 15:21:58 GMT' | ||
, 'content-type': 'application/json' | ||
, 'cache-control': 'must-revalidate' | ||
, 'status-code': 201 | ||
}) | ||
.delete(path + '/new/att?rev=1-921bd51ccdef5ab4c84b07bab7b80e7e') | ||
.reply(201, { ok: true, id:'new' }, | ||
{ location: location + '/new/att?rev=1-921bd51ccdef5ab4c84b07bab7b80e7e' | ||
, date: 'Wed, 30 Nov 2011 15:21:58 GMT' | ||
, 'content-type': 'application/json' | ||
, 'cache-control': 'must-revalidate' | ||
, 'status-code': 201 | ||
}) | ||
; | ||
@@ -21,8 +57,8 @@ function db(i) { return nano.use(db_name(i)); } | ||
tests.att_des_ok = function (e,b) { | ||
nano.db.destroy(db_name("a")); | ||
this.t.notOk(e); | ||
this.t.ok(b.ok); | ||
this.t.equal(b.id, "new"); | ||
this.t.notOk(e, 'No Error'); | ||
this.t.ok(b.ok, 'Ok is there'); | ||
this.t.equal(b.id, "new", 'Id is "new"'); | ||
this.t.ok(couchdb.isDone(), 'Nock not done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
@@ -7,4 +8,40 @@ , nano = require('../../nano')(cfg) | ||
, pixel = "Qk06AAAAAAAAADYAAAAoAAAAAQAAAP////8BABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA==" | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('a')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a'), | ||
date: 'Fri, 02 Dec 2011 16:34:28 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a') + '/new/att', '"Hello"') | ||
.reply(201, "{\"ok\":true,\"id\":\"new\",\"rev\":\"1-5142a2e74e1ec33e6e5b621418210283\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/new/att', | ||
etag: '"1-5142a2e74e1ec33e6e5b621418210283"', | ||
date: 'Fri, 02 Dec 2011 16:34:29 GMT', | ||
'content-type': 'text/plain;charset=utf-8', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a') + '/new/att?rev=1-5142a2e74e1ec33e6e5b621418210283' | ||
, new Buffer(pixel, 'base64').toString()) | ||
.reply(201, "{\"ok\":true,\"id\":\"new\",\"rev\":\"2-3b1f88c637fde74a486cf3ce5558b47e\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/new/att', | ||
etag: '"2-3b1f88c637fde74a486cf3ce5558b47e"', | ||
date: 'Fri, 02 Dec 2011 16:34:29 GMT', | ||
'content-type': 'text/plain;charset=utf-8', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('a') + '/new/att?rev=2-3b1f88c637fde74a486cf3ce5558b47e') | ||
.reply(200, new Buffer(pixel, 'base64'), { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"2-3b1f88c637fde74a486cf3ce5558b47e"', | ||
date: 'Fri, 02 Dec 2011 16:34:30 GMT', | ||
'content-type': 'image/bmp', | ||
'content-md5': 'Ow9j2dR0Qm58Qi3z8p2w3A==', | ||
'content-length': '58', | ||
'cache-control': 'must-revalidate', | ||
'accept-ranges': 'bytes' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -17,6 +54,6 @@ | ||
function(e,b) { | ||
if(e) { callback(e); nano.db.destroy(db_name("a")); } | ||
if(e) { callback(e); } | ||
db("a").attachment.insert("new", "att", buffer, "image/bmp", {rev: b.rev}, | ||
function (e2,b2) { | ||
if(e2) { callback(e2); nano.db.destroy(db_name("a")); } | ||
if(e2) { callback(e2); } | ||
db("a").attachment.get("new", "att", {rev: b2.rev}, callback); | ||
@@ -29,8 +66,8 @@ }); | ||
tests.att_get_ok = function (e,b) { | ||
nano.db.destroy(db_name("a")); | ||
this.t.notOk(e); | ||
this.t.notOk(e, 'No Error'); | ||
var from_buffer = new Buffer(b, "binary").toString("base64"); | ||
this.t.equal(from_buffer, pixel); | ||
this.t.equal(from_buffer, pixel, 'Buffer is pixel'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
@@ -6,4 +7,24 @@ , nano = require('../../nano')(cfg) | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name("a")) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)' | ||
, location: cfg.url + '/' + db_name("a") | ||
, date: 'Fri, 02 Dec 2011 00:21:46 GMT' | ||
, 'content-type': 'application/json' | ||
, 'content-length': '12' | ||
, 'cache-control': 'must-revalidate' | ||
}) | ||
.put('/' + db_name("a") + '/new/att', '"Hello World!"') | ||
.reply(201, "{\"ok\":true,\"id\":\"new\",\"rev\":\"1-921bd51ccdef5ab4c84b07bab7b80e7e\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name("a") + '/new/att', | ||
etag: '"1-921bd51ccdef5ab4c84b07bab7b80e7e"', | ||
date: 'Fri, 02 Dec 2011 00:21:46 GMT', | ||
'content-type': 'text/plain;charset=utf-8', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -18,8 +39,8 @@ | ||
tests.att_new_doc_ok = function (e,b) { | ||
nano.db.destroy(db_name("a")); | ||
this.t.notOk(e); | ||
this.t.ok(b.ok); | ||
this.t.equal(b.id, "new"); | ||
this.t.notOk(e, 'No errrs'); | ||
this.t.ok(b.ok, 'Im oh a OK'); | ||
this.t.equal(b.id, "new", "Id is new"); | ||
this.t.ok(couch.isDone(), 'Nock not done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, fs = require('fs') | ||
@@ -7,4 +8,44 @@ , cfg = require('../../cfg/tests.js') | ||
, db_name = require('../utils').db_name("att_pi") | ||
, pixel = "Qk06AAAAAAAAADYAAAAoAAAAAQAAAP////8BABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA=="; | ||
, pixel = "Qk06AAAAAAAAADYAAAAoAAAAAQAAAP////8BABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA==" | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('a')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a'), | ||
date: 'Fri, 02 Dec 2011 19:06:26 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a') + '/new/att', '"Hello"') | ||
.reply(201, "{\"ok\":true,\"id\":\"new\",\"rev\":\"1-5142a2e74e1ec33e6e5b621418210283\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/new/att', | ||
etag: '"1-5142a2e74e1ec33e6e5b621418210283"', | ||
date: 'Fri, 02 Dec 2011 19:06:26 GMT', | ||
'content-type': 'text/plain;charset=utf-8', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.put( '/' + db_name('a') + | ||
'/new/att?rev=1-5142a2e74e1ec33e6e5b621418210283' | ||
, new Buffer(pixel, 'base64').toString()) | ||
.reply(201, "{\"ok\":true,\"id\":\"new\",\"rev\":\"2-3b1f88c637fde74a486cf3ce5558b47e\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/new/att', | ||
etag: '"2-3b1f88c637fde74a486cf3ce5558b47e"', | ||
date: 'Fri, 02 Dec 2011 19:06:27 GMT', | ||
'content-type': 'text/plain;charset=utf-8', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('a') + | ||
'/new/att?rev=2-3b1f88c637fde74a486cf3ce5558b47e') | ||
.reply(200, new Buffer(pixel, 'base64'), | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"2-3b1f88c637fde74a486cf3ce5558b47e"', | ||
date: 'Fri, 02 Dec 2011 19:06:27 GMT', | ||
'content-type': 'image/bmp', | ||
'content-md5': 'Ow9j2dR0Qm58Qi3z8p2w3A==', | ||
'content-length': '58', | ||
'cache-control': 'must-revalidate', | ||
'accept-ranges': 'bytes' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -32,7 +73,7 @@ function file_name(i) { return __dirname + "/." + i + "-tmp.bmp"; } | ||
tests.att_pipe_ok = function () { | ||
nano.db.destroy(db_name("a")); | ||
this.t.equal(fs.readFileSync(file_name("a")).toString("base64"), pixel); | ||
fs.unlinkSync(file_name("a")); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
, nano = require('../../nano')(cfg) | ||
, db_name = require('../utils').db_name("att_up") | ||
, pixel = "Qk06AAAAAAAAADYAAAAoAAAAAQAAAP////8BABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA==" | ||
, tests = exports | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('b')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b'), | ||
date: 'Fri, 02 Dec 2011 18:49:22 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('b') + '/new/att', '"Hello World!"') | ||
.reply(201, "{\"ok\":true,\"id\":\"new\",\"rev\":\"1-921bd51ccdef5ab4c84b07bab7b80e7e\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b') + '/new/att', | ||
etag: '"1-921bd51ccdef5ab4c84b07bab7b80e7e"', | ||
date: 'Fri, 02 Dec 2011 18:49:23 GMT', | ||
'content-type': 'text/plain;charset=utf-8', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.put( '/' + db_name('b') + '/new/att?rev=1-921bd51ccdef5ab4c84b07bab7b80e7e' | ||
, new Buffer(pixel, 'base64').toString()) | ||
.reply(201, "{\"ok\":true,\"id\":\"new\",\"rev\":\"2-c6d2cd80113d505ec29430ac0859b41b\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b') + '/new/att', | ||
etag: '"2-c6d2cd80113d505ec29430ac0859b41b"', | ||
date: 'Fri, 02 Dec 2011 18:50:44 GMT', | ||
'content-type': 'text/plain;charset=utf-8', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
tests.att_doc = function (callback) { | ||
var pixel = "Qk06AAAAAAAAADYAAAAoAAAAAQAAAP////8BABgAAAAAAAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA==" | ||
, buffer = new Buffer(pixel, 'base64'); | ||
var buffer = new Buffer(pixel, 'base64'); | ||
nano.db.create(db_name("b"), function () { | ||
@@ -24,8 +52,8 @@ db("b").attachment.insert("new", "att", "Hello World!", "text/plain", | ||
tests.att_doc_ok = function (e,b) { | ||
nano.db.destroy(db_name("b")); | ||
this.t.notOk(e); | ||
this.t.ok(b.ok); | ||
this.t.equal(b.id, "new"); | ||
this.t.notOk(e, 'No errs'); | ||
this.t.ok(b.ok, 'Ok'); | ||
this.t.equal(b.id, "new", 'Id is new'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, async = require('async') | ||
@@ -7,4 +8,46 @@ , cfg = require('../../cfg/tests.js') | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name("a")) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name("a"), | ||
date: 'Fri, 02 Dec 2011 00:34:57 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name("a") + '/foobar', {"foo":"bar"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foobar\",\"rev\":\"1-4c6114c65e295552ab1019e2b046b10e\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name("a") + '/foobar', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 00:34:58 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name("a") + '/barfoo', {"bar": "foo"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"barfoo\",\"rev\":\"1-41412c293dade3fe73279cba8b4cece4\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name("a") + '/barfoo', | ||
etag: '"1-41412c293dade3fe73279cba8b4cece4"', | ||
date: 'Fri, 02 Dec 2011 00:34:58 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name("a") + '/foobaz', {"foo":"baz"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foobaz\",\"rev\":\"1-cfa20dddac397da5bf0be2b50fb472fe\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name("a") + '/foobaz', | ||
etag: '"1-cfa20dddac397da5bf0be2b50fb472fe"', | ||
date: 'Fri, 02 Dec 2011 00:34:58 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name("a") + '/_changes?since=2') | ||
.reply(200, "{\"results\":[\n{\"seq\":3,\"id\":\"foobaz\",\"changes\":[{\"rev\":\"1-cfa20dddac397da5bf0be2b50fb472fe\"}]}\n],\n\"last_seq\":3}\n\n", { 'transfer-encoding': 'chunked', | ||
server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"78IVA6O2WBXVUGGXYKZ7V2GBH"', | ||
date: 'Fri, 02 Dec 2011 00:34:58 GMT', | ||
'content-type': 'application/json', | ||
'cache-control': 'must-revalidate' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -26,8 +69,8 @@ | ||
tests.changes_db_ok = function (e,b) { | ||
nano.db.destroy(db_name("a")); | ||
this.t.notOk(e); | ||
this.t.equal(b.results.length,1); | ||
this.t.equal(b.last_seq,3); | ||
this.t.notOk(e, 'No Error'); | ||
this.t.equal(b.results.length,1, 'Gets one result'); | ||
this.t.equal(b.last_seq,3, 'Last seq is 3'); | ||
this.t.ok(couch.isDone(), 'Nock not done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, async = require('async') | ||
@@ -7,4 +8,57 @@ , cfg = require('../../cfg/tests.js') | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name("1")) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name("1") + '', | ||
date: 'Fri, 02 Dec 2011 01:27:15 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name("1") + '/foobar', {"foo":"bar"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foobar\",\"rev\":\"1-4c6114c65e295552ab1019e2b046b10e\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name("1") + '/foobar', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 01:27:15 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name("1") + '/barfoo', {"bar":"foo"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"barfoo\",\"rev\":\"1-41412c293dade3fe73279cba8b4cece4\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name("1") + '/barfoo', | ||
etag: '"1-41412c293dade3fe73279cba8b4cece4"', | ||
date: 'Fri, 02 Dec 2011 01:27:15 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name("1") + '/foobaz', {"foo":"baz"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foobaz\",\"rev\":\"1-cfa20dddac397da5bf0be2b50fb472fe\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name("1") + '/foobaz', | ||
etag: '"1-cfa20dddac397da5bf0be2b50fb472fe"', | ||
date: 'Fri, 02 Dec 2011 01:27:15 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.delete('/' + db_name("1") + '/foobaz?rev=1-cfa20dddac397da5bf0be2b50fb472fe') | ||
.reply(200, "{\"ok\":true,\"id\":\"foobaz\",\"rev\":\"2-a2a31b340cec15e18fbe6c82db6d2c2a\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"2-a2a31b340cec15e18fbe6c82db6d2c2a"', | ||
date: 'Fri, 02 Dec 2011 01:27:16 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.post('/' + db_name("1") + '/_compact') | ||
.reply(202, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 01:27:16 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name("1") + '') | ||
.reply(200, "{\"db_name\":\"" + db_name("1") + "\",\"doc_count\":3,\"doc_del_count\":0,\"update_seq\":4,\"purge_seq\":0,\"compact_running\":false,\"disk_size\":8281,\"instance_start_time\":\"1322789235294158\",\"disk_format_version\":5,\"committed_update_seq\":4}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 01:27:17 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '218', | ||
'cache-control': 'must-revalidate' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -18,3 +72,3 @@ | ||
, function(cb) { db('1').insert({"foo": "baz"},"foobaz", | ||
function (e,b) { db('1').destroy("foobaz", b._rev, cb); }); } | ||
function (e,b) { db('1').destroy("foobaz", b.rev, cb); }); } | ||
], | ||
@@ -30,8 +84,8 @@ function(err, results){ | ||
tests.compact_db_ok = function (err,list) { | ||
nano.db.destroy(db_name('1')); | ||
this.t.notOk(err); | ||
this.t.equal(list.doc_count, 3); | ||
this.t.equal(list.doc_del_count, 0); | ||
this.t.notOk(err, 'No err'); | ||
this.t.equal(list.doc_count, 3, 'Doc count is 3'); | ||
this.t.equal(list.doc_del_count, 0, 'No deleted documents'); | ||
this.t.ok(couch.isDone(), 'Nock not done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
, nano = require('../../nano')(cfg) | ||
, db_name = require('../utils').db_name("db_cr") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('1')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1'), | ||
date: 'Fri, 02 Dec 2011 01:44:15 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }); | ||
tests.create_db = function (callback) { | ||
nano.db.destroy(db_name('1'), function () { | ||
nano.db.create(db_name('1'), callback); | ||
}); | ||
nano.db.create(db_name('1'), callback); | ||
}; | ||
tests.create_db_ok = function (e,b) { | ||
nano.db.destroy(db_name('1')); | ||
this.t.notOk(e); | ||
this.t.equal(b.ok, true); | ||
this.t.notOk(e, 'Error shouldnt exist'); | ||
this.t.equal(b.ok, true, 'Ok must be returned'); | ||
this.t.ok(couch.isDone(), 'Nock not done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
, nano = require('../../nano')(cfg) | ||
, db_name = require('../utils').db_name("db_de") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('1')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1'), | ||
date: 'Fri, 02 Dec 2011 01:50:45 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.delete('/' + db_name('1')) | ||
.reply(200, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 01:50:46 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }); | ||
tests.destroy_db = function (callback) { | ||
@@ -14,6 +32,7 @@ nano.db.create(db_name('1'), function () { | ||
tests.destroy_db_ok = function (e,b) { | ||
this.t.notOk(e); | ||
this.t.equal(b.ok, true); | ||
this.t.notOk(e, 'Error says Yey'); | ||
this.t.equal(b.ok, true, '{ok: yeah}'); | ||
this.t.ok(couch.isDone(), 'Nock not done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
, nano = require('../../nano')(cfg) | ||
, db_name = require('../utils').db_name("db_ge") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('1')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1'), | ||
date: 'Fri, 02 Dec 2011 02:00:17 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('1')) | ||
.reply(200, "{\"db_name\":\"" + db_name('1') + "\",\"doc_count\":0,\"doc_del_count\":0,\"update_seq\":0,\"purge_seq\":0,\"compact_running\":false,\"disk_size\":79,\"instance_start_time\":\"1322791217213709\",\"disk_format_version\":5,\"committed_update_seq\":0}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 02:00:17 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '216', | ||
'cache-control': 'must-revalidate' }); | ||
tests.get_db = function (callback) { | ||
@@ -17,9 +35,9 @@ nano.db.create(db_name('1'), function () { | ||
tests.get_db_ok = function (e,b) { | ||
nano.db.destroy(db_name('1')); | ||
this.t.notOk(e); | ||
this.t.equal(b.doc_count,0); | ||
this.t.equal(b.doc_del_count,0); | ||
this.t.equal(b.db_name,db_name('1')); | ||
this.t.notOk(e, 'No errors'); | ||
this.t.equal(b.doc_count,0, 'No docs'); | ||
this.t.equal(b.doc_del_count,0, 'No deleted docs'); | ||
this.t.equal(b.db_name,db_name('1'), 'DB name is correct'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
, nano = require('../../nano')(cfg) | ||
, db_name = require('../utils').db_name("db_li") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('1')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1'), | ||
date: 'Fri, 02 Dec 2011 02:15:54 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/_all_dbs') | ||
.reply(200, "[\"" + db_name('1') + "\"]\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 02:15:54 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '81', | ||
'cache-control': 'must-revalidate' }); | ||
tests.list_db = function (callback) { | ||
@@ -14,7 +32,7 @@ nano.db.create(db_name('1'), function () { | ||
tests.list_db_ok = function (e,b) { | ||
nano.db.destroy(db_name('1')); | ||
this.t.notOk(e); | ||
this.t.notEqual(b.indexOf(db_name('1')),-1); | ||
this.t.notOk(e, 'Exception free since teh last run'); | ||
this.t.notEqual(b.indexOf(db_name('1')),-1, 'I can haz db name?!'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, async = require('async') | ||
@@ -6,4 +7,62 @@ , cfg = require('../../cfg/tests.js') | ||
, db_name = require('../utils').db_name("db_re") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('1')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: '' + cfg.url + '/' + db_name('1'), | ||
date: 'Fri, 02 Dec 2011 02:29:28 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '_replica') | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '_replica', | ||
date: 'Fri, 02 Dec 2011 02:29:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/foobaz', {"foo":"baz"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foobaz\",\"rev\":\"1-cfa20dddac397da5bf0be2b50fb472fe\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/foobaz', | ||
etag: '"1-cfa20dddac397da5bf0be2b50fb472fe"', | ||
date: 'Fri, 02 Dec 2011 02:29:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/barfoo', {"bar":"foo"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"barfoo\",\"rev\":\"1-41412c293dade3fe73279cba8b4cece4\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/barfoo', | ||
etag: '"1-41412c293dade3fe73279cba8b4cece4"', | ||
date: 'Fri, 02 Dec 2011 02:29:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/foobar', {"foo":"bar"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foobar\",\"rev\":\"1-4c6114c65e295552ab1019e2b046b10e\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/foobar', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 02:29:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.post('/_replicate', | ||
{ "source": db_name('1') | ||
, "target": db_name('1') + "_replica" | ||
}) | ||
.reply(200, "{\"ok\":true,\"session_id\":\"47c3b30bde0d3bd943f5530aaec65602\",\"source_last_seq\":3,\"replication_id_version\":2,\"history\":[{\"session_id\":\"47c3b30bde0d3bd943f5530aaec65602\",\"start_time\":\"Fri, 02 Dec 2011 02:29:29 GMT\",\"end_time\":\"Fri, 02 Dec 2011 02:29:29 GMT\",\"start_last_seq\":0,\"end_last_seq\":3,\"recorded_seq\":3,\"missing_checked\":0,\"missing_found\":3,\"docs_read\":3,\"docs_written\":3,\"doc_write_failures\":0}]}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 02:29:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '402', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('1') + '_replica/_all_docs') | ||
.reply(200, "{\"total_rows\":3,\"offset\":0,\"rows\":[\r\n{\"id\":\"barfoo\",\"key\":\"barfoo\",\"value\":{\"rev\":\"1-41412c293dade3fe73279cba8b4cece4\"}},\r\n{\"id\":\"foobar\",\"key\":\"foobar\",\"value\":{\"rev\":\"1-4c6114c65e295552ab1019e2b046b10e\"}},\r\n{\"id\":\"foobaz\",\"key\":\"foobaz\",\"value\":{\"rev\":\"1-cfa20dddac397da5bf0be2b50fb472fe\"}}\r\n]}\n", { 'transfer-encoding': 'chunked', | ||
server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"B0AI082A5BICTO8T8KCPEAN3Q"', | ||
date: 'Fri, 02 Dec 2011 02:29:30 GMT', | ||
'content-type': 'application/json', | ||
'cache-control': 'must-revalidate' }); | ||
tests.replicate_db = function (callback) { | ||
@@ -28,9 +87,8 @@ nano.db.create(db_name('1'), function () { | ||
tests.replicate_db_ok = function (e,b) { | ||
nano.db.destroy(db_name('1')); | ||
nano.db.destroy(db_name('1')+"_replica"); | ||
this.t.notOk(e); | ||
this.t.equal(b.total_rows, 3); | ||
this.t.ok(b.rows); | ||
this.t.notOk(e, 'Y U NO ERR?'); | ||
this.t.equal(b.total_rows, 3, 'I have 3 rows'); | ||
this.t.ok(b.rows, 'And that means I have rows. Nuno is stoopid.'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, async = require('async') | ||
@@ -6,4 +7,28 @@ , cfg = require('../../cfg/tests.js') | ||
, db_name = require('../utils').db_name("doc_bu") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('a')) | ||
.reply(201, "{\"ok\":true}\n" | ||
, { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a'), | ||
date: 'Fri, 02 Dec 2011 19:18:16 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.post('/' + db_name('a') + '/_bulk_docs' | ||
, { "docs": | ||
[ {"key": "baz","name": "bazzel"} | ||
, {"key": "bar", "name": "barry"} | ||
] | ||
}) | ||
.reply(201, "[{\"id\":\"b31761fe89e0d343c41d3cdbd9004eb7\",\"rev\":\"1-f5f3f3e496c72307975a69c73fd53d42\"},{\"id\":\"b31761fe89e0d343c41d3cdbd9005632\",\"rev\":\"1-8ad0e70d5e6edd474ec190eac2376bde\"}]\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 19:18:17 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '172', | ||
'cache-control': 'must-revalidate' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -22,9 +47,9 @@ | ||
tests.bulk_docs_ok = function (e,b) { | ||
nano.db.destroy(db_name("a")); | ||
this.t.notOk(e); | ||
this.t.equal(b.length, 2); | ||
this.t.ok(b[0].id); | ||
this.t.ok(b[1].id); | ||
this.t.notOk(e, 'No error'); | ||
this.t.equal(b.length, 2, 'Two docs'); | ||
this.t.ok(b[0].id, 'First got id'); | ||
this.t.ok(b[1].id, 'Second got id'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
, nano = require('../../nano')(cfg) | ||
, db_name = require('../utils').db_name("doc_de") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('1')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1'), | ||
date: 'Fri, 02 Dec 2011 19:23:54 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/foo', {"foo": "bar"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foo\",\"rev\":\"1-4c6114c65e295552ab1019e2b046b10e\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/foo', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 19:23:54 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.delete('/' + db_name('1') + | ||
'/foo?rev=1-4c6114c65e295552ab1019e2b046b10e') | ||
.reply(200, "{\"ok\":true,\"id\":\"foo\",\"rev\":\"2-185ccf92154a9f24a4f4fd12233bf463\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"2-185ccf92154a9f24a4f4fd12233bf463"', | ||
date: 'Fri, 02 Dec 2011 19:23:55 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }); | ||
tests.destroy_doc = function (callback) { | ||
@@ -20,9 +50,9 @@ var db = nano.use(db_name('1')); | ||
tests.destroy_doc_ok = function (e,b) { | ||
nano.db.destroy(db_name('1')); | ||
this.t.notOk(e); | ||
this.t.ok(b.ok); | ||
this.t.equal(b.id, "foo"); | ||
this.t.ok(b.rev); | ||
this.t.notOk(e, 'No errors'); | ||
this.t.ok(b.ok, 'I got ok'); | ||
this.t.equal(b.id, "foo", 'Id is foo'); | ||
this.t.ok(b.rev, 'Got rev'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
, nano = require('../../nano')(cfg) | ||
, db_name = require('../utils').db_name("doc_ge") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('b')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b'), | ||
date: 'Fri, 02 Dec 2011 19:28:49 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a'), | ||
date: 'Fri, 02 Dec 2011 19:28:49 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a') + '/foo', {"foo": "bar"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foo\",\"rev\": \"1-4c6114c65e295552ab1019e2b046b10e\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/foo', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 19:28:49 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('b') + '/foo', {"foo": "bar"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foo\",\"rev\": \"1-4c6114c65e295552ab1019e2b046b10e\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b') + '/foo', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 19:28:49 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('a') + '/foo') | ||
.reply(200, "{\"_id\": \"foo\",\"_rev\": \"1-4c6114c65e295552ab1019e2b046b10e\",\"foo\": \"bar\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 19:28:50 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '70', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('b') + '/foo', {"foo": "bar"}) | ||
.reply(409, | ||
"{\"error\": \"conflict\",\"reason\": \"Document update conflict.\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 19:28:50 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '58', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('b') + '/foo?revs_info=true') | ||
.reply(200, "{\"_id\": \"foo\",\"_rev\": \"1-4c6114c65e295552ab1019e2b046b10e\",\"foo\": \"bar\",\"_revs_info\": [{\"rev\":\"1-4c6114c65e295552ab1019e2b046b10e\",\"status\": \"available\"}]}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 19:28:50 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '151', | ||
'cache-control': 'must-revalidate' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -18,7 +80,7 @@ | ||
tests.get_doc_ok = function (e,b) { | ||
nano.db.destroy(db_name('a')); | ||
this.t.notOk(e); | ||
this.t.ok(b._rev); | ||
this.t.equal(b._id, "foo"); | ||
this.t.equal(b.foo, "bar"); | ||
this.t.notOk(e, 'No excs'); | ||
this.t.ok(b._rev, 'I got rev'); | ||
this.t.equal(b._id, "foo", 'My id is foo'); | ||
this.t.equal(b.foo, "bar", 'My foo is bar'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
@@ -37,9 +99,9 @@ | ||
tests.get_doc_params_ok = function (e,b) { | ||
nano.db.destroy(db_name('b')); | ||
this.t.notOk(e); | ||
this.t.ok(b._revs_info); | ||
this.t.equal(b._id, "foo"); | ||
this.t.equal(b.foo, "bar"); | ||
this.t.notOk(e, 'Err, not here'); | ||
this.t.ok(b._revs_info, 'Got revs info'); | ||
this.t.equal(b._id, "foo", 'Id is food'); | ||
this.t.equal(b.foo, "bar", 'Bar is in foo'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
@@ -6,4 +7,41 @@ , nano = require('../../nano')(cfg) | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('b')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b'), | ||
date: 'Fri, 02 Dec 2011 20:15:11 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: 'http://nodejsbug.iriscouch.com/v061_doc_ina', | ||
date: 'Fri, 02 Dec 2011 20:15:11 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.post('/' + db_name('a'), {"foo": "bar"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"cb691f3e73482a0fb7e76bd3350037b4\",\"rev\": \"1-4c6114c65e295552ab1019e2b046b10e\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + | ||
'/cb691f3e73482a0fb7e76bd3350037b4', | ||
date: 'Fri, 02 Dec 2011 20:15:11 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '95', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('b') + '/some%2Fpath', {"foo": "bar"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"some/path\",\"rev\": \"1-4c6114c65e295552ab1019e2b046b10e\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b') + '/some/path', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 20:15:11 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '72', | ||
'cache-control': 'must-revalidate' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -18,7 +56,7 @@ | ||
tests.insert_doc_ok = function (e,b) { | ||
nano.db.destroy(db_name("a")); | ||
this.t.notOk(e); | ||
this.t.ok(b.ok); | ||
this.t.ok(b.rev); | ||
this.t.ok(b.id); | ||
this.t.notOk(e, 'No eerz'); | ||
this.t.ok(b.ok, 'This is ok'); | ||
this.t.ok(b.rev, 'I GOT REVZ'); | ||
this.t.ok(b.id, 'I got Id!'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
@@ -33,9 +71,9 @@ | ||
tests.insert_doc_path_ok = function (e,b) { | ||
nano.db.destroy(db_name("b")); | ||
this.t.notOk(e); | ||
this.t.ok(b.ok); | ||
this.t.ok(b.rev); | ||
this.t.equal(b.id, "some/path"); | ||
this.t.notOk(e, 'Y U NO Errs'); | ||
this.t.ok(b.ok, 'I got ok'); | ||
this.t.ok(b.rev, 'I got rev'); | ||
this.t.equal(b.id, "some/path", 'I got id, not over 21 though'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, async = require('async') | ||
@@ -7,4 +8,143 @@ , cfg = require('../../cfg/tests.js') | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('a')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a'), | ||
date: 'Fri, 02 Dec 2011 20:26:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('c')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('c'), | ||
date: 'Fri, 02 Dec 2011 20:26:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('b')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b'), | ||
date: 'Fri, 02 Dec 2011 20:26:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a') + '/foobar', {"foo": "bar"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foobar\",\"rev\": \"1-4c6114c65e295552ab1019e2b046b10e\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/foobar', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 20:26:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a') + '/barfoo', {"bar": "foo"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"barfoo\",\"rev\": \"1-41412c293dade3fe73279cba8b4cece4\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/barfoo', | ||
etag: '"1-41412c293dade3fe73279cba8b4cece4"', | ||
date: 'Fri, 02 Dec 2011 20:26:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('c') + '/foobar', {"foo": "bar"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foobar\",\"rev\": \"1-4c6114c65e295552ab1019e2b046b10e\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('c') + '/foobar', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 20:26:29 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a') + '/foobaz', {"foo": "baz"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foobaz\",\"rev\": \"1-cfa20dddac397da5bf0be2b50fb472fe\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/foobaz', | ||
etag: '"1-cfa20dddac397da5bf0be2b50fb472fe"', | ||
date: 'Fri, 02 Dec 2011 20:26:30 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('c') + '/barfoo', {"bar": "foo"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"barfoo\",\"rev\": \"1-41412c293dade3fe73279cba8b4cece4\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('c') + '/barfoo', | ||
etag: '"1-41412c293dade3fe73279cba8b4cece4"', | ||
date: 'Fri, 02 Dec 2011 20:26:30 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('a') + '/_all_docs') | ||
.reply(200, "{\"total_rows\": 3,\"offset\": 0,\"rows\": [\r\n{\"id\": \"barfoo\",\"key\": \"barfoo\",\"value\": {\"rev\": \"1-41412c293dade3fe73279cba8b4cece4\"}},\r\n{\"id\" :\"foobar\",\"key\": \"foobar\",\"value\": {\"rev\":\"1-4c6114c65e295552ab1019e2b046b10e\"}},\r\n{\"id\": \"foobaz\",\"key\": \"foobaz\",\"value\": {\"rev\":\"1-cfa20dddac397da5bf0be2b50fb472fe\"}}\r\n]}\n", | ||
{ 'transfer-encoding': 'chunked', | ||
server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"AXA5PYPHH9S5SIRQ1NH1N0896"', | ||
date: 'Fri, 02 Dec 2011 20:26:30 GMT', | ||
'content-type': 'application/json', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('b') + '/foobar', {"foo": "bar"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foobar\",\"rev\": \"1-4c6114c65e295552ab1019e2b046b10e\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b') + '/foobar', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 20:26:30 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('b') + '/barfoo', {"bar": "foo"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"barfoo\",\"rev\": \"1-41412c293dade3fe73279cba8b4cece4\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b') + '/barfoo', | ||
etag: '"1-41412c293dade3fe73279cba8b4cece4"', | ||
date: 'Fri, 02 Dec 2011 20:26:30 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('b') + '/foobaz', {"foo": "baz"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foobaz\",\"rev\": \"1-cfa20dddac397da5bf0be2b50fb472fe\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('b') + '/foobaz', | ||
etag: '"1-cfa20dddac397da5bf0be2b50fb472fe"', | ||
date: 'Fri, 02 Dec 2011 20:26:30 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('c') + '/foobaz', {"foo": "baz"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foobaz\",\"rev\": \"1-cfa20dddac397da5bf0be2b50fb472fe\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('c') + '/foobaz', | ||
etag: '"1-cfa20dddac397da5bf0be2b50fb472fe"', | ||
date: 'Fri, 02 Dec 2011 20:26:30 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.delete('/' + db_name('a')) | ||
.reply(200, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 20:26:30 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('b') + '/_all_docs?limit=1') | ||
.reply(200, "{\"total_rows\": 3,\"offset\": 0,\"rows\": [\r\n{\"id\": \"barfoo\",\"key\": \"barfoo\",\"value\": {\"rev\": \"1-41412c293dade3fe73279cba8b4cece4\"}}\r\n]}\n", | ||
{ 'transfer-encoding': 'chunked', | ||
server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"7FE6ZA8SPA15QUXDRRHGRLWKO"', | ||
date: 'Fri, 02 Dec 2011 20:26:30 GMT', | ||
'content-type': 'application/json', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('c') + '/_all_docs?startkey=%22c%22') | ||
.reply(200, "{\"total_rows\": 3,\"offset\": 1,\"rows\": [\r\n{\"id\": \"foobar\",\"key\": \"foobar\",\"value\": {\"rev\": \"1-4c6114c65e295552ab1019e2b046b10e\"}},\r\n{\"id\": \"foobaz\",\"key\": \"foobaz\",\"value\": {\"rev\":\"1-cfa20dddac397da5bf0be2b50fb472fe\"}}\r\n]}\n", | ||
{ 'transfer-encoding': 'chunked', | ||
server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"B5NTIXF7OO6RFK10FU94G5O3Y"', | ||
date: 'Fri, 02 Dec 2011 20:26:31 GMT', | ||
'content-type': 'application/json', | ||
'cache-control': 'must-revalidate' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -26,6 +166,6 @@ | ||
tests.list_doc_ok = function (e,b) { | ||
nano.db.destroy(db_name('a')); | ||
this.t.notOk(e); | ||
this.t.equal(b.total_rows,3); | ||
this.t.ok(b.rows); | ||
this.t.notOk(e, 'No err'); | ||
this.t.equal(b.total_rows,3, '3 Rows'); | ||
this.t.ok(b.rows, 'Got rows'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
@@ -51,7 +191,7 @@ | ||
tests.ns_list_doc_ok = function (e,b) { | ||
nano.db.destroy(db_name('b')); | ||
this.t.notOk(e); | ||
this.t.equal(b.rows.length,1); | ||
this.t.equal(b.total_rows,3); | ||
this.t.ok(b.rows); | ||
this.t.notOk(e, 'Not Err'); | ||
this.t.equal(b.rows.length,1, 'One Row'); | ||
this.t.equal(b.total_rows,3, 'Out of 3'); | ||
this.t.ok(b.rows, 'I got Rows'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
@@ -73,9 +213,9 @@ | ||
tests.list_doc_params_ok = function (e,b) { | ||
nano.db.destroy(db_name('c')); | ||
this.t.notOk(e); | ||
this.t.equal(b.rows.length,2); | ||
this.t.equal(b.total_rows,3); | ||
this.t.ok(b.rows); | ||
this.t.notOk(e, 'No errs'); | ||
this.t.equal(b.rows.length,2, 'Two rows returned'); | ||
this.t.equal(b.total_rows,3, 'Out of 3'); | ||
this.t.ok(b.rows, 'That means we got rows'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
, nano = require('../../nano')(cfg) | ||
, db_name = require('../utils').db_name("doc_up") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('a')) | ||
.reply(201, "{\"ok\":true}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a'), | ||
date: 'Fri, 02 Dec 2011 19:38:03 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a') + '/foo', {"foo": "bar"}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foo\",\"rev\": \"1-4c6114c65e295552ab1019e2b046b10e\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/foo', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 19:38:04 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('a') + '/foo', | ||
{ "_rev": "1-4c6114c65e295552ab1019e2b046b10e" | ||
, "foo": "baz" | ||
}) | ||
.reply(201, "{\"ok\": true,\"id\": \"foo\",\"rev\": \"2-cfcd6781f13994bde69a1c3320bfdadb\"}\n", | ||
{ server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('a') + '/foo', | ||
etag: '"2-cfcd6781f13994bde69a1c3320bfdadb"', | ||
date: 'Fri, 02 Dec 2011 19:38:04 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }); | ||
function db(i) { return nano.use(db_name(i)); } | ||
@@ -18,9 +52,9 @@ | ||
tests.update_doc_ok = function (e,b) { | ||
nano.db.destroy(db_name('a')); | ||
this.t.notOk(e); | ||
this.t.equal(b.id, "foo"); | ||
this.t.ok(b.ok); | ||
this.t.ok(b.rev); | ||
this.t.notOk(e, 'I got err free status'); | ||
this.t.equal(b.id, "foo", 'My filename is foo'); | ||
this.t.ok(b.ok, 'I am now ok'); | ||
this.t.ok(b.rev, 'I got rev'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename,tests,module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, cfg = require('../../cfg/tests.js') | ||
, nano = require('../../nano') | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.get('/acb') | ||
.reply(404, "{\"error\":\"not_found\",\"reason\":\"no_db_file\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 02:53:14 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '44', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/adb') | ||
.reply(404, "{\"error\":\"not_found\",\"reason\":\"no_db_file\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 02:53:14 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '44', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/adb') | ||
.reply(404, "{\"error\":\"not_found\",\"reason\":\"no_db_file\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 02:53:14 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '44', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/a') | ||
.reply(404, "{\"error\":\"not_found\",\"reason\":\"no_db_file\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 02:53:14 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '44', | ||
'cache-control': 'must-revalidate' }); | ||
tests.url = function (callback) { callback(null,nano('http://someurl.com')); }; | ||
@@ -7,0 +36,0 @@ tests.url_ok = function (_,n) { this.t.equal(n.config.url, "http://someurl.com"); }; |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, async = require('async') | ||
@@ -6,4 +7,69 @@ , cfg = require('../../cfg/tests.js') | ||
, db_name = require('../utils').db_name("view_co") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('1')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1'), | ||
date: 'Fri, 02 Dec 2011 03:09:53 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/foobar', {"foo":"bar"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foobar\",\"rev\":\"1-4c6114c65e295552ab1019e2b046b10e\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/foobar', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 03:09:54 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/barfoo', {"bar":"foo"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"barfoo\",\"rev\":\"1-41412c293dade3fe73279cba8b4cece4\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/barfoo', | ||
etag: '"1-41412c293dade3fe73279cba8b4cece4"', | ||
date: 'Fri, 02 Dec 2011 03:09:54 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/foobaz', {"foo":"baz"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foobaz\",\"rev\":\"1-cfa20dddac397da5bf0be2b50fb472fe\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/foobaz', | ||
etag: '"1-cfa20dddac397da5bf0be2b50fb472fe"', | ||
date: 'Fri, 02 Dec 2011 03:09:54 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/_design/alice', | ||
{ "views": | ||
{"by_id":{"map":"function(doc) { emit(doc._id, doc); }"}}}) | ||
.reply(201, "{\"ok\":true,\"id\":\"_design/alice\",\"rev\":\"1-14e6bcd59de8d02b840c4db3c95637c5\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/_design/alice', | ||
etag: '"1-14e6bcd59de8d02b840c4db3c95637c5"', | ||
date: 'Fri, 02 Dec 2011 03:09:55 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '76', | ||
'cache-control': 'must-revalidate' }) | ||
.delete('/' + db_name('1') + '/foobaz?rev=1-cfa20dddac397da5bf0be2b50fb472fe') | ||
.reply(200, "{\"ok\":true,\"id\":\"foobaz\",\"rev\":\"2-a2a31b340cec15e18fbe6c82db6d2c2a\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"2-a2a31b340cec15e18fbe6c82db6d2c2a"', | ||
date: 'Fri, 02 Dec 2011 03:09:55 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '69', | ||
'cache-control': 'must-revalidate' }) | ||
.post('/' + db_name('1') + '/_compact/alice') | ||
.reply(202, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
date: 'Fri, 02 Dec 2011 03:09:55 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('1') + '/_design/alice/_view/by_id') | ||
.reply(200, "{\"total_rows\":2,\"offset\":0,\"rows\":[\r\n{\"id\":\"barfoo\",\"key\":\"barfoo\",\"value\":{\"_id\":\"barfoo\",\"_rev\":\"1-41412c293dade3fe73279cba8b4cece4\",\"bar\":\"foo\"}},\r\n{\"id\":\"foobar\",\"key\":\"foobar\",\"value\":{\"_id\":\"foobar\",\"_rev\":\"1-4c6114c65e295552ab1019e2b046b10e\",\"foo\":\"bar\"}}\r\n]}\n", { 'transfer-encoding': 'chunked', | ||
server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"AZYB6353W6O0LS9Z4M13CDL7R"', | ||
date: 'Fri, 02 Dec 2011 03:09:56 GMT', | ||
'content-type': 'application/json', | ||
'cache-control': 'must-revalidate' }); | ||
tests.compact_view = function (callback) { | ||
@@ -33,7 +99,7 @@ nano.db.create(db_name('1'), function () { | ||
tests.compact_view_ok = function (err,view) { | ||
nano.db.destroy(db_name('1')); | ||
this.t.notOk(err); | ||
this.t.equal(view.total_rows, 2); | ||
this.t.notOk(err, 'STD Free, no errs'); | ||
this.t.equal(view.total_rows, 2, 'Total rows is two'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename, tests, module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, async = require('async') | ||
@@ -7,4 +8,60 @@ , cfg = require('../../cfg/tests.js') | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('1')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1'), | ||
date: 'Fri, 02 Dec 2011 02:58:50 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/foo', {"foo":"bar"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"foo\",\"rev\":\"1-4c6114c65e295552ab1019e2b046b10e\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/foo', | ||
etag: '"1-4c6114c65e295552ab1019e2b046b10e"', | ||
date: 'Fri, 02 Dec 2011 02:58:51 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/baz', {"foo":"baz"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"baz\",\"rev\":\"1-cfa20dddac397da5bf0be2b50fb472fe\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/baz', | ||
etag: '"1-cfa20dddac397da5bf0be2b50fb472fe"', | ||
date: 'Fri, 02 Dec 2011 02:58:51 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/bar', {"bar":"foo"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"bar\",\"rev\":\"1-41412c293dade3fe73279cba8b4cece4\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/bar', | ||
etag: '"1-41412c293dade3fe73279cba8b4cece4"', | ||
date: 'Fri, 02 Dec 2011 02:58:51 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '66', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('1') + '/_design/alice' | ||
, { "views": | ||
{ "by_id": | ||
{ "map": "function(doc) { emit(doc._id, doc); }" | ||
} | ||
} | ||
}) | ||
.reply(201, "{\"ok\":true,\"id\":\"_design/alice\",\"rev\":\"1-14e6bcd59de8d02b840c4db3c95637c5\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('1') + '/_design/alice', | ||
etag: '"1-14e6bcd59de8d02b840c4db3c95637c5"', | ||
date: 'Fri, 02 Dec 2011 02:58:52 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '76', | ||
'cache-control': 'must-revalidate' }) | ||
.post('/' + db_name('1') + '/_design/alice/_view/by_id?include_docs=true' | ||
, {"keys":["foo","bar"]}) | ||
.reply(200, "{\"total_rows\":3,\"offset\":2,\"rows\":[\r\n{\"id\":\"foo\",\"key\":\"foo\",\"value\":{\"_id\":\"foo\",\"_rev\":\"1-4c6114c65e295552ab1019e2b046b10e\",\"foo\":\"bar\"},\"doc\":{\"_id\":\"foo\",\"_rev\":\"1-4c6114c65e295552ab1019e2b046b10e\",\"foo\":\"bar\"}},\r\n{\"id\":\"bar\",\"key\":\"bar\",\"value\":{\"_id\":\"bar\",\"_rev\":\"1-41412c293dade3fe73279cba8b4cece4\",\"bar\":\"foo\"},\"doc\":{\"_id\":\"bar\",\"_rev\":\"1-41412c293dade3fe73279cba8b4cece4\",\"bar\":\"foo\"}}\r\n]}\n", { 'transfer-encoding': 'chunked', | ||
server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"MZ8GS7KA63WNTZ3RI58JU64R"', | ||
date: 'Fri, 02 Dec 2011 02:58:52 GMT', | ||
'content-type': 'application/json', | ||
'cache-control': 'must-revalidate' }); | ||
tests.multi_doc = function (callback) { | ||
@@ -31,9 +88,9 @@ nano.db.create(db_name('1'), function () { | ||
tests.multi_doc_ok = function (err,view) { | ||
nano.db.destroy(db_name('1')); | ||
this.t.notOk(err); | ||
this.t.equal(view.rows.length, 2); | ||
this.t.equal(view.rows[0].id, 'foo'); | ||
this.t.equal(view.rows[1].id, 'bar'); | ||
this.t.notOk(err, 'I got no errors'); | ||
this.t.equal(view.rows.length, 2, 'And two rows'); | ||
this.t.equal(view.rows[0].id, 'foo', 'Got an id of foo'); | ||
this.t.equal(view.rows[1].id, 'bar', 'And an id of bar'); | ||
this.t.ok(couch.isDone(), 'Nock is done'); | ||
}; | ||
ensure(__filename, tests, module,process.argv[2]); |
var ensure = require('ensure') | ||
, nock = require('nock') | ||
, async = require('async') | ||
@@ -6,34 +7,66 @@ , cfg = require('../../cfg/tests.js') | ||
, db_name = require('../utils').db_name("view_qu") | ||
, tests = exports; | ||
, tests = exports | ||
, couch | ||
; | ||
couch = nock(cfg.url) | ||
.put('/' + db_name('2')) | ||
.reply(201, "{\"ok\":true}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('2'), | ||
date: 'Fri, 02 Dec 2011 03:19:26 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '12', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('2') + '/randall', | ||
{ "name": "Randall" | ||
, "city": "San Francisco // CA, USA" | ||
}) | ||
.reply(201, "{\"ok\":true,\"id\":\"randall\",\"rev\":\"1-37dfdbddd84354050154f2e39b6bda90\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('2') + '/randall', | ||
etag: '"1-37dfdbddd84354050154f2e39b6bda90"', | ||
date: 'Fri, 02 Dec 2011 03:19:26 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '70', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('2') + '/nuno', | ||
{ "name": "Nuno" | ||
, "city": "Porto // PT, Portugal" | ||
}) | ||
.reply(201, "{\"ok\":true,\"id\":\"nuno\",\"rev\":\"1-638d3cde87402899b4aacc6490c01d3b\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('2') + '/nuno', | ||
etag: '"1-638d3cde87402899b4aacc6490c01d3b"', | ||
date: 'Fri, 02 Dec 2011 03:19:26 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '67', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('2') + '/derek', | ||
{ "name": "Derek" | ||
, "city": "San Francisco // CA, USA"}) | ||
.reply(201, "{\"ok\":true,\"id\":\"derek\",\"rev\":\"1-f849b3014fcb990a74fca741edf34fea\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('2') + '/derek', | ||
etag: '"1-f849b3014fcb990a74fca741edf34fea"', | ||
date: 'Fri, 02 Dec 2011 03:19:26 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '68', | ||
'cache-control': 'must-revalidate' }) | ||
.put('/' + db_name('2') + '/_design/people', | ||
{"views": {"by_name_and_city": | ||
{"map":"function(doc) { emit([doc.name, doc.city], doc._id); }"}}}) | ||
.reply(201, "{\"ok\":true,\"id\":\"_design/people\",\"rev\":\"1-81370b2d35e19e28d491e81922bb9fba\"}\n", { server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
location: cfg.url + '/' + db_name('2') + '/_design/people', | ||
etag: '"1-81370b2d35e19e28d491e81922bb9fba"', | ||
date: 'Fri, 02 Dec 2011 03:19:27 GMT', | ||
'content-type': 'application/json', | ||
'content-length': '77', | ||
'cache-control': 'must-revalidate' }) | ||
.get('/' + db_name('2') + '/_design/people/_view/by_name_and_city?key=%5B%22Derek%22%2C%22San%20Francisco%20%2F%2F%20CA%2C%20USA%22%5D') | ||
.reply(200, "{\"total_rows\":3,\"offset\":0,\"rows\":[\r\n{\"id\":\"derek\",\"key\":[\"Derek\",\"San Francisco // CA, USA\"],\"value\":\"derek\"}\r\n]}\n", { 'transfer-encoding': 'chunked', | ||
server: 'CouchDB/1.1.1 (Erlang OTP/R14B04)', | ||
etag: '"49G7ABUI3FOA4M2EHE2GG2OES"', | ||
date: 'Fri, 02 Dec 2011 03:19:27 GMT', | ||
'content-type': 'application/json', | ||
'cache-control': 'must-revalidate' }); | ||
function db_gen(i) { return nano.use(db_name(i)); } | ||
tests.recursive_create_view = function (tried,callback) { | ||
if(typeof tried === 'function') { | ||
callback = tried; | ||
tried = {tried:0, max_retries:2}; | ||
} | ||
nano.db.create(db_name('1'), function () { | ||
var db = db_gen('1'); | ||
db.view('cats','by_id', function (e,b,h) { | ||
if(tried.tried === tried.max_retries) { return callback('failed'); } | ||
if(e && e.message === 'missing') { | ||
return db.insert({"views": { "by_id": { | ||
"map": "function(doc) { emit(doc._id, doc); }" } } | ||
}, '_design/cats', function () { | ||
tried.tried += 1; | ||
tests.recursive_create_view(tried,callback); | ||
}); | ||
} | ||
return callback(e,b,h); | ||
}); | ||
}); | ||
}; | ||
tests.recursive_create_view_ok = function (e,view) { | ||
nano.db.destroy(db_name('1')); | ||
this.t.notOk(e); | ||
this.t.equal(view.total_rows,0); | ||
}; | ||
function complex_key_test(cb,i,params,map) { | ||
@@ -67,3 +100,2 @@ map = map ? map : 'emit([doc.city,doc.name], doc._id);'; | ||
tests.array_in_key_ok = function (e,b,h) { | ||
nano.db.destroy(db_name('2')); | ||
this.t.notOk(e); | ||
@@ -70,0 +102,0 @@ this.t.equal(b.rows.length,1); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
106097
2319
0
210
3
+ Addedrequest@2.2.0(transitive)
- Removedrequest@2.2.9(transitive)
Updatedrequest@2.2.0