Skip to content
This repository
Browse code

# 0.7.0

* added support for arbitrary paths in
* document paths are now EncodeURIComponent by default, use path to override
* new error handling code, hopefully more readable
* added auto db.use when a database is present in the uri that was provided
* updated to request 2.1.1 on frozen deps
  • Loading branch information...
commit ecd5b1a1d9ac3fe1255ac8d3e374dcb3a4fb4a37 1 parent 403949c
Nuno Job authored
7 CHANGELOG.md
Source Rendered
... ... @@ -0,0 +1,7 @@
  1 +# 0.7.0
  2 +
  3 +* added support for arbitrary paths in `nano.request`
  4 +* document paths are now EncodeURIComponent by default, use path to override
  5 +* new error handling code, hopefully more readable
  6 +* added auto db.use when a database is present in the uri that was provided
  7 +* updated to request 2.1.1 on frozen deps
18 LICENSE
... ... @@ -1,13 +1,13 @@
1   -Copyright 2011 Nuno Job <nunojob.com>
  1 +copyright 2011 nuno job <nunojob.com> (oO)--',--
2 2
3   -Licensed under the Apache License, Version 2.0 (the "License");
4   -you may not use this file except in compliance with the License.
5   -You may obtain a copy of the License at
  3 +licensed under the apache license, version 2.0 (the "license");
  4 +you may not use this file except in compliance with the license.
  5 +you may obtain a copy of the license at
6 6
7 7 http://www.apache.org/licenses/LICENSE-2.0
8 8
9   -Unless required by applicable law or agreed to in writing, software
10   -distributed under the License is distributed on an "AS IS" BASIS,
11   -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   -See the License for the specific language governing permissions and
13   -limitations under the License.
  9 +unless required by applicable law or agreed to in writing, software
  10 +distributed under the license is distributed on an "as is" basis,
  11 +without warranties or conditions of any kind, either express or implied.
  12 +see the license for the specific language governing permissions and
  13 +limitations under the license.
2  README.md
Source Rendered
@@ -123,7 +123,7 @@ to get a document in a specific rev an advanced user might do:
123 123 function (_,_,b) { console.log(b) }
124 124 );
125 125
126   -this is the same as (assuming `alice = nano.use("alice");`):
  126 +this is the same as (assuming `alice = require('nano')('http://localhost:5984/alice')`):
127 127
128 128 alice.get("rabbit", {rev: "1-967a00dff5e02add41819138abb3284d"},
129 129 function (_,_,b) { console.log(b) }
4 cfg/tests.js
@@ -30,4 +30,8 @@ cfg.url = function (){
30 30 ":" + cfg.port;
31 31 }();
32 32
  33 +cfg.db_url = function (postfix) {
  34 + return cfg.url + '/' + postfix;
  35 +};
  36 +
33 37 module.exports = exports = cfg;
123 error.js
... ... @@ -1,55 +1,56 @@
1   -var STATUS_CODES = { '100': 'Continue',
2   - '101': 'Switching Protocols',
3   - '102': 'Processing',
4   - '200': 'OK',
5   - '201': 'Created',
6   - '202': 'Accepted',
7   - '203': 'Non-Authoritative Information',
8   - '204': 'No Content',
9   - '205': 'Reset Content',
10   - '206': 'Partial Content',
11   - '207': 'Multi-Status',
12   - '300': 'Multiple Choices',
13   - '301': 'Moved Permanently',
14   - '302': 'Moved Temporarily',
15   - '303': 'See Other',
16   - '304': 'Not Modified',
17   - '305': 'Use Proxy',
18   - '307': 'Temporary Redirect',
19   - '400': 'Bad Request',
20   - '401': 'Unauthorized',
21   - '402': 'Payment Required',
22   - '403': 'Forbidden',
23   - '404': 'Not Found',
24   - '405': 'Method Not Allowed',
25   - '406': 'Not Acceptable',
26   - '407': 'Proxy Authentication Required',
27   - '408': 'Request Time-out',
28   - '409': 'Conflict',
29   - '410': 'Gone',
30   - '411': 'Length Required',
31   - '412': 'Precondition Failed',
32   - '413': 'Request Entity Too Large',
33   - '414': 'Request-URI Too Large',
34   - '415': 'Unsupported Media Type',
35   - '416': 'Requested Range Not Satisfiable',
36   - '417': 'Expectation Failed',
37   - '418': 'I\'m a teapot',
38   - '422': 'Unprocessable Entity',
39   - '423': 'Locked',
40   - '424': 'Failed Dependency',
41   - '425': 'Unordered Collection',
42   - '426': 'Upgrade Required',
43   - '500': 'Internal Server Error',
44   - '501': 'Not Implemented',
45   - '502': 'Bad Gateway',
46   - '503': 'Service Unavailable',
47   - '504': 'Gateway Time-out',
48   - '505': 'HTTP Version not supported',
49   - '506': 'Variant Also Negotiates',
50   - '507': 'Insufficient Storage',
51   - '509': 'Bandwidth Limit Exceeded',
52   - '510': 'Not Extended' };
  1 +var STATUS_CODES = { '100': 'Continue'
  2 + ,'101': 'Switching Protocols'
  3 + ,'102': 'Processing'
  4 + ,'200': 'OK'
  5 + ,'201': 'Created'
  6 + ,'202': 'Accepted'
  7 + ,'203': 'Non-Authoritative Information'
  8 + ,'204': 'No Content'
  9 + ,'205': 'Reset Content'
  10 + ,'206': 'Partial Content'
  11 + ,'207': 'Multi-Status'
  12 + ,'300': 'Multiple Choices'
  13 + ,'301': 'Moved Permanently'
  14 + ,'302': 'Moved Temporarily'
  15 + ,'303': 'See Other'
  16 + ,'304': 'Not Modified'
  17 + ,'305': 'Use Proxy'
  18 + ,'307': 'Temporary Redirect'
  19 + ,'400': 'Bad Request'
  20 + ,'401': 'Unauthorized'
  21 + ,'402': 'Payment Required'
  22 + ,'403': 'Forbidden'
  23 + ,'404': 'Not Found'
  24 + ,'405': 'Method Not Allowed'
  25 + ,'406': 'Not Acceptable'
  26 + ,'407': 'Proxy Authentication Required'
  27 + ,'408': 'Request Time-out'
  28 + ,'409': 'Conflict'
  29 + ,'410': 'Gone'
  30 + ,'411': 'Length Required'
  31 + ,'412': 'Precondition Failed'
  32 + ,'413': 'Request Entity Too Large'
  33 + ,'414': 'Request-URI Too Large'
  34 + ,'415': 'Unsupported Media Type'
  35 + ,'416': 'Requested Range Not Satisfiable'
  36 + ,'417': 'Expectation Failed'
  37 + ,'418': 'I\'m a teapot'
  38 + ,'422': 'Unprocessable Entity'
  39 + ,'423': 'Locked'
  40 + ,'424': 'Failed Dependency'
  41 + ,'425': 'Unordered Collection'
  42 + ,'426': 'Upgrade Required'
  43 + ,'500': 'Internal Server Error'
  44 + ,'501': 'Not Implemented'
  45 + ,'502': 'Bad Gateway'
  46 + ,'503': 'Service Unavailable'
  47 + ,'504': 'Gateway Time-out'
  48 + ,'505': 'HTTP Version not supported'
  49 + ,'506': 'Variant Also Negotiates'
  50 + ,'507': 'Insufficient Storage'
  51 + ,'509': 'Bandwidth Limit Exceeded'
  52 + ,'510': 'Not Extended'
  53 + };
53 54 /*
54 55 * generic error
55 56 *
@@ -84,18 +85,18 @@ var STATUS_CODES = { '100': 'Continue',
84 85 *
85 86 * @return an augmented error that helps you know more than the stack trace
86 87 */
87   -function gen_err(error,code,request,http_code,type) {
88   - if(!type) { type = http_code; http_code = null; }
89   - if(!error) { error = new Error(STATUS_CODES[http_code] || "Unknown Error"); }
90   - if(typeof http_code !== "number") { http_code = 500; }
  88 +function gen_err(scope,error,code,request,status_code) {
  89 + error = error || STATUS_CODES[status_code] || 'Unknown Error';
  90 + code = code || 'unknown';
  91 + status_code = typeof status_code === 'number' && status_code || 500;
  92 + request = request || {};
91 93 if(typeof error === 'string') { error = new Error(error); }
92   -
93 94 error.error = code;
94   - error.status_code = http_code;
95   - error.namespace = type;
  95 + error.status_code = status_code;
  96 + error.scope = scope;
96 97 error.request = request;
97 98 return error;
98 99 }
99 100
100   -exports.request_err = function (e,c,r,h) { return gen_err(e,c,r,h,"request");};
101   -exports.couch_err = function (e,c,r,h) { return gen_err(e,c,r,h,"couch"); };
  101 +exports.request = function (e,c,r,h) { return gen_err('request',e,c,r,h);};
  102 +exports.couch = function (e,c,r,h) { return gen_err('couch',e,c,r,h); };
41 nano.js
@@ -18,6 +18,7 @@ var request = require('request')
18 18 , fs = require('fs')
19 19 , qs = require('querystring')
20 20 , _ = require('underscore')
  21 + , u = require('url')
21 22 , error = require('./error')
22 23 , default_url = "http://localhost:5984"
23 24 , nano;
@@ -32,7 +33,7 @@ var request = require('request')
32 33 * dinosaurs spaceships!
33 34 */
34 35 module.exports = exports = nano = function database_module(cfg) {
35   - var public_functions = {};
  36 + var public_functions = {}, path, db;
36 37 if(typeof cfg === "string") {
37 38 if(/^https?:/.test(cfg)) { cfg = {url: cfg}; } // url
38 39 else {
@@ -40,6 +41,10 @@ module.exports = exports = nano = function database_module(cfg) {
40 41 catch(e) { console.error("bad cfg: couldn't load file"); }
41 42 }
42 43 }
  44 + if(!cfg) {
  45 + console.error("bad cfg: you passed undefined");
  46 + cfg = {};
  47 + }
43 48 if(cfg.proxy) {
44 49 request = request.defaults({proxy: cfg.proxy}); // proxy support
45 50 }
@@ -47,9 +52,10 @@ module.exports = exports = nano = function database_module(cfg) {
47 52 console.error("bad cfg: using default=" + default_url);
48 53 cfg = {url: default_url}; // if everything else fails, use default
49 54 }
  55 + path = u.parse(cfg.url);
50 56
51 57 /****************************************************************************
52   - * relax *
  58 + * relax *
53 59 ****************************************************************************/
54 60 /*
55 61 * relax
@@ -71,6 +77,7 @@ module.exports = exports = nano = function database_module(cfg) {
71 77 * @param {opts:object} request options; e.g. {db: "test", method: "GET"}
72 78 * {opts.db:string} database name
73 79 * {opts.method:string:optional} http method, defaults to "GET"
  80 + * {opts.path:string:optional} a full path, override `doc` and `att`
74 81 * {opts.doc:string:optional} document name
75 82 * {opts.att:string:optional} attachment name
76 83 * {opts.content_type:string:optional} content type, default to json
@@ -88,10 +95,13 @@ module.exports = exports = nano = function database_module(cfg) {
88 95 , status_code
89 96 , parsed
90 97 , rh;
91   - if(opts.doc) {
92   - url += "/" + opts.doc; // add the document to the url
  98 + if(opts.path) {
  99 + url += "/" + opts.path;
  100 + }
  101 + else if(opts.doc) {
  102 + url += "/" + encodeURIComponent(opts.doc); // add the document to the url
93 103 if(opts.att) { url += "/" + opts.att; } // add the attachment to the url
94   - }
  104 + }
95 105 if(opts.encoding && callback) {
96 106 req.encoding = opts.encoding;
97 107 delete req.headers["content-type"];
@@ -112,7 +122,7 @@ module.exports = exports = nano = function database_module(cfg) {
112 122 request(req, function(e,h,b){
113 123 rh = (h && h.headers || {});
114 124 rh['status-code'] = status_code = (h && h.statusCode || 500);
115   - if(e) { return callback(error.request_err(e,"socket",req,status_code),rh,b); }
  125 + if(e) { return callback(error.request(e,"socket",req,status_code),rh,b); }
116 126 delete rh.server; // prevent security vunerabilities related to couchdb
117 127 delete rh["content-length"]; // prevent problems with trims and stalled responses
118 128 try { parsed = JSON.parse(b); } catch (err) { parsed = b; } // did we get json or binary?
@@ -120,7 +130,7 @@ module.exports = exports = nano = function database_module(cfg) {
120 130 callback(null,rh,parsed);
121 131 }
122 132 else { // proxy the error directly from couchdb
123   - callback(error.couch_err(parsed.reason,parsed.error,req,status_code),rh,parsed);
  133 + callback(error.couch(parsed.reason,parsed.error,req,status_code),rh,parsed);
124 134 }
125 135 });
126 136 }
@@ -211,7 +221,7 @@ module.exports = exports = nano = function database_module(cfg) {
211 221 callback = design_name;
212 222 design_name = null;
213 223 }
214   - return relax({db: db_name, doc: "_compact", att: design_name, method: "POST"},callback);
  224 + return relax({db: db_name, path: ("_compact" + design_name), method: "POST"},callback);
215 225 }
216 226
217 227 /*
@@ -231,7 +241,7 @@ module.exports = exports = nano = function database_module(cfg) {
231 241 callback = params;
232 242 params = {};
233 243 }
234   - return relax({db: db_name, doc: "_changes", params: params, method: "GET"},callback);
  244 + return relax({db: db_name, path: "_changes", params: params, method: "GET"},callback);
235 245 }
236 246
237 247 /*
@@ -331,7 +341,7 @@ module.exports = exports = nano = function database_module(cfg) {
331 341 callback = params;
332 342 params = {};
333 343 }
334   - return relax({db: db_name, doc: "_all_docs", method: "GET", params: params},callback);
  344 + return relax({db: db_name, path: "_all_docs", method: "GET", params: params},callback);
335 345 }
336 346
337 347 /*
@@ -344,7 +354,7 @@ module.exports = exports = nano = function database_module(cfg) {
344 354 * @see relax
345 355 */
346 356 function bulk_docs(docs,callback) {
347   - return relax({db: db_name, doc: "_bulk_docs", body: docs, method: "POST"},callback);
  357 + return relax({db: db_name, path: "_bulk_docs", body: docs, method: "POST"},callback);
348 358 }
349 359
350 360 /**************************************************************************
@@ -458,7 +468,14 @@ module.exports = exports = nano = function database_module(cfg) {
458 468 , relax: relax // alias
459 469 , dinosaur: relax // alias
460 470 };
461   - return public_functions;
  471 +
  472 + // does the user want a database, or nano?
  473 + if(!_.isEmpty(path.pathname.split('/')[1])) {
  474 + db = path.pathname.split('/')[1];
  475 + cfg.url = path.protocol + '//' + path.host; // reset url
  476 + return document_module(db);
  477 + }
  478 + else { return public_functions; }
462 479 };
463 480
464 481 /*
10 node_modules/request/main.js
@@ -57,7 +57,7 @@ function isReadStream (rs) {
57 57
58 58 function copy (obj) {
59 59 var o = {}
60   - for (i in obj) o[i] = obj[i]
  60 + for (var i in obj) o[i] = obj[i]
61 61 return o
62 62 }
63 63
@@ -74,7 +74,7 @@ function Request (options) {
74 74 options = {uri:options}
75 75 }
76 76
77   - for (i in options) {
  77 + for (var i in options) {
78 78 this[i] = options[i]
79 79 }
80 80 if (!this.pool) this.pool = globalPool
@@ -281,7 +281,7 @@ Request.prototype.request = function () {
281 281 }
282 282 }
283 283 if (dest.setHeader) {
284   - for (i in response.headers) {
  284 + for (var i in response.headers) {
285 285 dest.setHeader(i, response.headers[i])
286 286 }
287 287 dest.statusCode = response.statusCode
@@ -337,7 +337,7 @@ Request.prototype.request = function () {
337 337 options.headers['content-type'] = mimetypes.lookup(src.path.slice(src.path.lastIndexOf('.')+1))
338 338 } else {
339 339 if (src.headers) {
340   - for (i in src.headers) {
  340 + for (var i in src.headers) {
341 341 if (!options.headers[i]) {
342 342 options.headers[i] = src.headers[i]
343 343 }
@@ -405,7 +405,7 @@ request.defaults = function (options) {
405 405 var def = function (method) {
406 406 var d = function (opts, callback) {
407 407 if (typeof opts === 'string') opts = {uri:opts}
408   - for (i in options) {
  408 + for (var i in options) {
409 409 if (opts[i] === undefined) opts[i] = options[i]
410 410 }
411 411 return method(opts, callback)
4 package.json
... ... @@ -1,10 +1,10 @@
1 1 { "name": "nano"
2 2 , "description": "minimalistic couchdb driver for node.js"
3 3 , "homepage": "http://github.com/dscape/nano"
4   -, "version": "0.6.6"
  4 +, "version": "0.7.0"
5 5 , "author": "Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)"
6 6 , "keywords": ["couchdb", "data", "request", "json", "nosql", "micro", "nano"]
7   -, "dependencies": {"request": "~2.0.5", "underscore": "~1.1.7"}
  7 +, "dependencies": {"request": "~2.1.1", "underscore": "~1.1.7"}
8 8 , "devDependencies": { "async": "~0.1.9", "vows": "~0.5.10" }
9 9 , "main": "./nano.js"
10 10 , "engines" : { "node": ">=0.3.6" }
36 tests/doc/insert.js
... ... @@ -1,30 +1,50 @@
1 1 var vows = require('vows')
2 2 , assert = require('assert')
3 3 , cfg = require('../../cfg/tests.js')
4   - , nano = require('../../nano')(cfg)
5   - , db_name = "doc_in1"
6   - , db = nano.use(db_name);
  4 + , nano = require('../../nano')(cfg);
  5 +
  6 +function db_name(i) { return "doc_in" + i; }
  7 +function db(i) { return nano.use(db_name(i)); }
7 8
8 9 /*****************************************************************************
9 10 * insert_doc *
10 11 *****************************************************************************/
11 12 function insert_doc(callback) {
12   - nano.db.create(db_name, function () {
13   - db.insert({foo: "bar"}, callback);
  13 + nano.db.create(db_name("a"), function () {
  14 + db("a").insert({foo: "bar"}, callback);
14 15 });
15 16 }
16 17
17 18 function insert_doc_ok(e,h,b) {
18   - nano.db.destroy(db_name);
  19 + nano.db.destroy(db_name("a"));
19 20 assert.isNull(e);
20 21 assert.ok(b.ok);
21 22 assert.ok(b.rev);
22 23 assert.ok(b.id);
23 24 }
24 25
  26 +/*****************************************************************************
  27 + * insert_doc_path *
  28 + *****************************************************************************/
  29 +function insert_doc_path(callback) {
  30 + nano.db.create(db_name("b"), function () {
  31 + db("b").insert({foo: "bar"}, 'some/path', callback);
  32 + });
  33 +}
  34 +
  35 +function insert_doc_path_ok(e,h,b) {
  36 + nano.db.destroy(db_name("b"));
  37 + assert.isNull(e);
  38 + assert.ok(b.ok);
  39 + assert.ok(b.rev);
  40 + assert.equal(b.id, "some/path");
  41 +}
  42 +
25 43 vows.describe('db.insert').addBatch({
26 44 "insert_doc": {
27 45 topic: function () { insert_doc(this.callback); }
28   - , "=": insert_doc_ok
29   - }
  46 + , "=": insert_doc_ok },
  47 + "insert_doc_path": {
  48 + topic: function () { insert_doc_path(this.callback); }
  49 + , "=": insert_doc_path_ok }
30 50 }).exportTo(module);
82 tests/shared/cfg.js
@@ -10,6 +10,60 @@ function url(callback) { callback(null,nano('http://someurl.com')); }
10 10 function url_ok(_,n) { assert.equal(n.config.url, "http://someurl.com"); }
11 11
12 12 /*****************************************************************************
  13 + * url2 *
  14 + *****************************************************************************/
  15 +function url2(callback) { callback(null,nano('http://someurl.com/')); }
  16 +function url2_ok(_,n) { assert.equal(n.config.url, "http://someurl.com/"); }
  17 +
  18 +/*****************************************************************************
  19 + * url_db *
  20 + *****************************************************************************/
  21 +function url_db(callback) {
  22 + nano(cfg.db_url("adb")).info(callback);
  23 +}
  24 +function url_db_ok(e,h,b) {
  25 + assert.equal(e.message,"no_db_file");
  26 + assert.equal(e.error, "not_found");
  27 + assert.equal(e.request.uri, (cfg.url + '/adb'));
  28 +}
  29 +
  30 +/*****************************************************************************
  31 + * url_db2 *
  32 + *****************************************************************************/
  33 +function url_db2(callback) {
  34 + nano(cfg.db_url("adb/")).info(callback);
  35 +}
  36 +function url_db2_ok(e,h,b) {
  37 + assert.equal(e.message,"no_db_file");
  38 + assert.equal(e.error, "not_found");
  39 + assert.equal(e.request.uri, (cfg.url + '/adb'));
  40 +}
  41 +
  42 +/*****************************************************************************
  43 + * url_db3 *
  44 + *****************************************************************************/
  45 +function url_db3(callback) {
  46 + nano(cfg.db_url("adb/blergh")).info(callback);
  47 +}
  48 +function url_db3_ok(e,h,b) {
  49 + assert.equal(e.message,"no_db_file");
  50 + assert.equal(e.error, "not_found");
  51 + assert.equal(e.request.uri, (cfg.url + '/adb'));
  52 +}
  53 +
  54 +/*****************************************************************************
  55 + * url_db4 *
  56 + *****************************************************************************/
  57 +function url_db4(callback) {
  58 + nano(cfg.db_url("a/b/d/c/")).info(callback);
  59 +}
  60 +function url_db4_ok(e,h,b) {
  61 + assert.equal(e.message,"no_db_file");
  62 + assert.equal(e.error, "not_found");
  63 + assert.equal(e.request.uri, (cfg.url + '/a'));
  64 +}
  65 +
  66 +/*****************************************************************************
13 67 * file *
14 68 *****************************************************************************/
15 69 function file(callback) { callback(null,nano(__dirname+ '/../../cfg/tests.js')); }
@@ -38,11 +92,36 @@ function not_string_or_object(callback) {
38 92 function not_string_or_object_ok(_,e) {
39 93 assert.equal(e.config.url,"http://localhost:5984");
40 94 }
  95 +
  96 +/*****************************************************************************
  97 + * nano_undefined *
  98 + *****************************************************************************/
  99 +function nano_undefined(callback) {
  100 + callback(null,nano());
  101 +}
  102 +function nano_undefined_ok(_,e) {
  103 + assert.equal(e.config.url,"http://localhost:5984");
  104 +}
41 105
42 106 vows.describe('config').addBatch({
43 107 "url": {
44 108 topic: function () { url(this.callback); }
45 109 , "=": url_ok },
  110 + "url2": {
  111 + topic: function () { url2(this.callback); }
  112 + , "=": url2_ok },
  113 + "url_db": {
  114 + topic: function () { url_db(this.callback); }
  115 + , "=": url_db_ok },
  116 + "url_db2": {
  117 + topic: function () { url_db2(this.callback); }
  118 + , "=": url_db2_ok },
  119 + "url_db3": {
  120 + topic: function () { url_db3(this.callback); }
  121 + , "=": url_db3_ok },
  122 + "url_db4": {
  123 + topic: function () { url_db4(this.callback); }
  124 + , "=": url_db4_ok },
46 125 "file": {
47 126 topic: function () { file(this.callback); }
48 127 , "=": file_ok },
@@ -52,6 +131,9 @@ vows.describe('config').addBatch({
52 131 "object": {
53 132 topic: function () { object(this.callback); }
54 133 , "=": object_ok },
  134 + "nano_undefined": {
  135 + topic: function () { nano_undefined(this.callback); }
  136 + , "=": nano_undefined_ok },
55 137 "not_string_or_object": {
56 138 topic: function () { not_string_or_object(this.callback); }
57 139 , "=": not_string_or_object_ok }
12 tests/shared/error.js
@@ -6,28 +6,28 @@ var vows = require('vows')
6 6 * empty_error *
7 7 *****************************************************************************/
8 8 function empty_error(callback) {
9   - callback(null,err.couch_err(null,null,null,null));
  9 + callback(null,err.couch(null,null,null,null));
10 10 }
11 11
12 12 function empty_error_ok(_,e) {
13 13 assert.equal(e.message, "Unknown Error");
14 14 assert.equal(e.status_code, 500);
15   - assert.isNull(e.error);
16   - assert.isNull(e.request);
  15 + assert.equal(e.error, "unknown");
  16 + assert.ok(typeof e.request === 'object');
17 17 }
18 18
19 19 /*****************************************************************************
20 20 * error_412 *
21 21 *****************************************************************************/
22 22 function error_412(callback) {
23   - callback(null,err.couch_err(null,null,null,412));
  23 + callback(null,err.couch(null,null,null,412));
24 24 }
25 25
26 26 function error_412_ok(_,e) {
27 27 assert.equal(e.message, "Precondition Failed");
28 28 assert.equal(e.status_code, 412);
29   - assert.isNull(e.error);
30   - assert.isNull(e.request);
  29 + assert.equal(e.error, "unknown");
  30 + assert.ok(typeof e.request === 'object');
31 31 }
32 32
33 33 vows.describe('error').addBatch({

0 comments on commit ecd5b1a

Please sign in to comment.
Something went wrong with that request. Please try again.