Permalink
Browse files

minor changes to tests

  • Loading branch information...
dscape committed Sep 5, 2011
1 parent 4cd089f commit 55adcd418c03d0b25308ca2a3b31a7f7677de27d
Showing with 57 additions and 48 deletions.
  1. +1 −1 lib/nuvem/request.js
  2. +48 −43 test/json/find-qs.js
  3. +2 −1 test/json/find.js
  4. +2 −1 test/json/insert.js
  5. +2 −1 test/manage/info.js
  6. +2 −1 test/shared/error.js
View
@@ -43,7 +43,7 @@ module.exports = exports = function request_module(cfg) {
if(opts.path) { req.uri += "/" + opts.path; } // add the path to the url
}
if (opts.params && opts.params.customquery) {
- opts.params.customquery = encodeURIComponent(JSON.stringify(opts.params.customquery));
+ opts.params.customquery = JSON.stringify(opts.params.customquery);
}
req.uri += _.isEmpty(opts.params) ? "" : "?" + qs.stringify(opts.params);
if(!callback) { return request(req); } // no callback, pipe
View
@@ -4,61 +4,66 @@ var ensure = require('ensure')
, nuvem = require('../../index')
, helper = require('../helper')
, db = nuvem(cfg)
- , tests = exports;
+ , paths = ['soap', 'many', 'examples']
+ , docs = [{its: 'amazin'}, {run: 'in'}, {crazy: true} ]
+ , tests = exports
+ ;
-//tests.phrase = function (cb) {
-// helper.setup({db: db, salt: '_phrase'},function(e) {
-// if(e) { throw e; }
-// db.json.first('"in the snow"', cb);
-// });
-//};
-//
-//tests.phrase_ok = function(e,b,h) {
-// if(e) { throw e; }
-// assert.equal(h["status-code"],200);
-// assert.ok(b.uri.indexOf("/foo/bar/foobar") !== -1);
-// helper.teardown({db: db, salt: '_phrase'});
-//};
-//
-//tests.snow = function (cb) {
-// helper.setup({db: db, salt: '_snow'},function(e) {
-// if(e) { throw e; }
-// db.json.first('snow', cb);
-// });
-//};
-//
-//tests.snow_ok = function(e,b,h) {
-// if(e) { throw e; }
-// assert.equal(h["status-code"],200);
-// assert.ok(b.uri.indexOf("/foo/bar/foobar") !== -1);
-// helper.teardown({db: db, salt: '_snow'});
-//};
+tests.phrase = function (cb) {
+ helper.setup({db: db, salt: '_phrase'},function(e) {
+ if(e) { throw e; }
+ db.json.first('"in the snow"', cb);
+ });
+};
+
+tests.phrase_ok = function(e,b,h) {
+ if(e) { throw e; }
+ assert.equal(h["status-code"],200);
+ assert.ok(b.uri.indexOf("/foo/bar/foobar") !== -1);
+ helper.teardown({db: db, salt: '_phrase'});
+};
+
+tests.snow = function (cb) {
+ helper.setup({db: db, salt: '_snow'},function(e) {
+ if(e) { throw e; }
+ db.json.first('snow', cb);
+ });
+};
+
+tests.snow_ok = function(e,b,h) {
+ if(e) { throw e; }
+ assert.equal(h["status-code"],200);
+ assert.ok(b.uri.indexOf("/foo/bar/foobar") !== -1);
+ helper.teardown({db: db, salt: '_snow'});
+};
tests.collections = function (cb) {
- helper.setup({db: db, salt: '_collections', collections: ['dog','red']}
+ helper.setup({db: db, salt: '_collections', collections: ['dog','red']
+ , paths: paths, docs: docs }
, function(e) {
if(e) { throw e; }
- db.json.find('snow', { include: 'all' }, cb);
+ db.json.find('amazin', { include: 'all' }, cb);
});
};
tests.collections_ok = function (e,b,h) {
assert.isNull(e);
assert.ok(b.collections.indexOf('red')!==-1);
- helper.teardown({db: db, salt: '_collections'});
+ assert.ok(b.uri.indexOf("soap") !== -1);
+ helper.teardown({db: db, salt: '_collections', paths: paths});
};
-//tests.directories = function (cb) {
-// helper.setup({db: db, salt: '_directories'}, function(e){
-// if(e) { throw e; }
-// db.json.find('fox', { inDirectory: '/foo' }, cb);
-// });
-//};
-//
-//tests.directories_ok = function (e,b,h) {
-// assert.isNull(e);
-// assert.ok(b.uri.indexOf("another") !== -1);
-// helper.teardown({db: db, salt: '_directories'});
-//};
+tests.directories = function (cb) {
+ helper.setup({db: db, salt: '_directories'}, function(e){
+ if(e) { throw e; }
+ db.json.find('fox', { inDirectory: '/foo' }, cb);
+ });
+};
+
+tests.directories_ok = function (e,b,h) {
+ assert.isNull(e);
+ assert.ok(b.uri.indexOf("another") !== -1);
+ helper.teardown({db: db, salt: '_directories'});
+};
ensure(__filename, tests, module);
View
@@ -3,7 +3,8 @@ var ensure = require('ensure')
, cfg = require('../fixtures/marklogic.js')
, nuvem = require('../../index')
, db = nuvem(cfg)
- , tests = exports;
+ , tests = exports
+ ;
tests.bad_query = function (cb) { db.json.first(false, cb); };
View
@@ -3,7 +3,8 @@ var ensure = require('ensure')
, cfg = require('../fixtures/marklogic.js')
, nuvem = require('../../index')
, db = nuvem(cfg)
- , tests = exports;
+ , tests = exports
+ ;
tests.malformed = function (cb) { db.json.insert("a", "", cb); };
View
@@ -3,7 +3,8 @@ var ensure = require('ensure')
, cfg = require('../fixtures/marklogic.js')
, nuvem = require('../../index')
, db = nuvem(cfg)
- , tests = exports;
+ , tests = exports
+ ;
tests.info = function (cb) {
db.manage.info(cb);
View
@@ -2,9 +2,10 @@ var ensure = require('ensure')
, assert = require('assert')
, cfg = require('../fixtures/marklogic.js')
, nuvem = require('../../index')
+ , err = require('../../lib/nuvem/error')
, db = nuvem(cfg)
, tests = exports
- , err = require('../../lib/nuvem/error');
+ ;
tests.empty_error = function (callback) {
callback(null,err.socket(null,null,null,null));

0 comments on commit 55adcd4

Please sign in to comment.