This repository has been archived by the owner on Nov 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 157
/
cfg.js
84 lines (71 loc) · 3.51 KB
/
cfg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var ensure = require('ensure')
, nock = require('nock')
, cfg = require('../../cfg/tests.js')
, nano = require('../../nano')
, 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')); };
tests.url_ok = function (_,n) { this.t.equal(n.config.url, "http://someurl.com"); };
tests.url2 = function (callback) { callback(null,nano('http://someurl.com/')); };
tests.url2_ok = function (_,n) { this.t.equal(n.config.url, "http://someurl.com/"); };
tests.url_db = function (callback) { nano(cfg.url + "/adb").info(callback); };
tests.url_db_ok = function (e,b) {
this.t.equal(e.message,"no_db_file");
this.t.equal(e.error, "not_found");
this.t.equal(e.request.uri, (cfg.url + '/adb'));
};
tests.url_db2 = function (callback) { nano(cfg.url + "/acb/").info(callback); };
tests.url_db2_ok = function (e,b) {
this.t.equal(e.message,"no_db_file");
this.t.equal(e.error, "not_found");
this.t.equal(e.request.uri, (cfg.url + '/acb'));
};
tests.url_db3 = function (callback) { nano(cfg.url + "/adb/blergh").info(callback); };
tests.url_db3_ok = function (e,b) {
this.t.equal(e.message,"no_db_file");
this.t.equal(e.error, "not_found");
this.t.equal(e.request.uri, (cfg.url + '/adb'));
};
tests.url_db4 = function (callback) { nano(cfg.url + "/a/b/d/c/").info(callback); };
tests.url_db4_ok = function (e,b) {
this.t.equal(e.message,"no_db_file");
this.t.equal(e.error, "not_found");
this.t.equal(e.request.uri, (cfg.url + '/a'));
};
tests.file = function (callback) { callback(null,nano(__dirname+ '/../../cfg/tests.js')); };
tests.file_ok = function (_,n) { this.t.equal(n.config.url, cfg.url); };
tests.bad_file = function (callback) { callback(null,nano('notafile')); };
tests.bad_file_ok = function (_,e) { this.t.equal(e.config.url,"http://localhost:5984"); };
tests.obj_cfg = function (callback) { callback(null,nano(cfg)); };
tests.obj_cfg_ok = function (_,n) { this.t.equal(n.config.url, cfg.url); };
tests.not_string_or_object = function (callback) { callback(null,nano(false)); };
tests.not_string_or_object_ok = function (_,e) { this.t.equal(e.config.url,"http://localhost:5984"); };
tests.nano_undefined = function (callback) { callback(null,nano()); };
tests.nano_undefined_ok = function (_,e) { this.t.equal(e.config.url,"http://localhost:5984"); };
ensure(__filename,tests,module,process.argv[2]);