clerk 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- var clerk = require("../clerk");
4
- var expect = require("expect.js");
5
- var shared = require("./shared");
6
-
7
- var sinon = require("sinon");
8
-
9
- describe("clerk", function () {
10
- before(shared.clerkFactory);
11
-
12
- it("should delegate to clerk.make()", function () {
13
- sinon.spy(clerk, "make");
14
- clerk();
15
- expect(clerk.make.calledOnce).to.be.ok();
16
- clerk.make.restore();
17
- });
18
-
19
- describe("#make", function () {
20
-
21
- it("should make client", function () {
22
- var client = clerk.make();
23
- expect(client).to.be.a(clerk.Client);
24
- expect(client).to.have.property("uri", "http://127.0.0.1:5984");
25
- });
26
-
27
- it("should make client with URI", function () {
28
- var client = clerk.make("http://127.0.0.1:5984");
29
- expect(client).to.be.a(clerk.Client);
30
- expect(client).to.have.property("uri", "http://127.0.0.1:5984");
31
- });
32
-
33
- it("should make db with URI", function () {
34
- var db = clerk.make("http://127.0.0.1:5984/test");
35
- expect(db).to.be.a(clerk.DB);
36
- expect(db).to.have.property("uri", "http://127.0.0.1:5984/test");
37
- });
38
-
39
- });
40
-
41
- });
@@ -1,193 +0,0 @@
1
- "use strict";
2
-
3
- var clerk = require("../clerk");
4
- var expect = require("expect.js");
5
- var shared = require("./shared");
6
-
7
- describe("Client", function () {
8
-
9
- before(shared.clerkFactory);
10
-
11
- describe("#db", function () {
12
- it("should return DB object", function () {
13
- expect(this.db).to.be.a(clerk.DB);
14
- var uri = this.baseURL.replace(/^(https?:\/\/)([^@\/]+@)/, "$1") + "/" +
15
- this.dbname;
16
- expect(this.db).to.have.property("uri", uri);
17
- });
18
- });
19
-
20
- describe("#dbs", function () {
21
- it("shoud list databases", function (done) {
22
- this.client.dbs(function (err, body, status, headers, res) {
23
- if (!err) {
24
- expect(body).to.be.an("array");
25
- shared.shouldHave2xxStatus(status);
26
- }
27
- done(err);
28
- });
29
- });
30
- });
31
-
32
- describe("#uuids", function () {
33
-
34
- it("shoud return 1 uuid by default", function (done) {
35
- this.client.uuids(having(1, done));
36
- });
37
-
38
- shouldReturnUUIDs(1);
39
- shouldReturnUUIDs(2);
40
- shouldReturnUUIDs(3);
41
- shouldReturnUUIDs(100);
42
-
43
- function having(n, done) {
44
- return function (err, body, status, headers, res) {
45
- if (!err) {
46
- expect(body).to.have.property("uuids");
47
- expect(body).to.be.an("array");
48
- expect(body).to.have.length(n);
49
- shared.shouldHave2xxStatus(status);
50
- }
51
- done(err);
52
- };
53
- }
54
-
55
- function shouldReturnUUIDs(n) {
56
- it("shoud return " + n + " uuid", function (done) {
57
- this.client.uuids(n, having(n, done));
58
- });
59
- }
60
-
61
- });
62
-
63
- describe("#info", function () {
64
- it("shoud return server info", function (done) {
65
- this.client.info(function (err, body, status, headers, res) {
66
- if (!err) {
67
- expect(body).to.have.property("couchdb", "Welcome");
68
- expect(body).to.have.property("version");
69
- shared.shouldHave2xxStatus(status);
70
- }
71
- done(err);
72
- });
73
- });
74
- });
75
-
76
- describe("#stats", function () {
77
- it("shoud return server stats", function (done) {
78
- this.client.stats(function (err, body, status, headers, res) {
79
- if (!err) {
80
- expect(body).to.have.property("couchdb");
81
- expect(body).to.have.property("httpd");
82
- expect(body).to.have.property("httpd_request_methods");
83
- expect(body).to.have.property("httpd_status_codes");
84
- shared.shouldHave2xxStatus(status);
85
- }
86
- done(err);
87
- });
88
- });
89
- });
90
-
91
- describe("#log", function () {
92
- it("shoud return server log lines", function (done) {
93
- this.client.log(function (err, body, status, headers, res) {
94
- if (!err) {
95
- expect(body).to.be.ok();
96
- shared.shouldHave2xxStatus(status);
97
- }
98
- done(err);
99
- });
100
- });
101
- });
102
-
103
- describe("#tasks", function () {
104
- it("shoud return server running tasks", function (done) {
105
- this.client.tasks(function (err, body, status, headers, res) {
106
- if (!err) {
107
- expect(body).to.be.an("array");
108
- shared.shouldHave2xxStatus(status);
109
- }
110
- done(err);
111
- });
112
- });
113
- });
114
-
115
- describe("#config", function () {
116
-
117
- it("shoud return server config", function (done) {
118
- this.client.config(function (err, body, status, headers, res) {
119
- if (!err) {
120
- expect(body).to.be.an("object");
121
- expect(body).to.have.property("couchdb");
122
- expect(body).to.have.property("daemons");
123
- expect(body).to.have.property("httpd");
124
- shared.shouldHave2xxStatus(status);
125
- }
126
- done(err);
127
- });
128
- });
129
-
130
- it("shoud return server config object", function (done) {
131
- this.client.config("couchdb", function (err, body, status, headers, res) {
132
- if (!err) {
133
- expect(body).to.be.an("object");
134
- expect(body).to.have.property("database_dir");
135
- expect(body).to.have.property("delayed_commits");
136
- expect(body).to.have.property("max_document_size");
137
- shared.shouldHave2xxStatus(status);
138
- }
139
- done(err);
140
- });
141
- });
142
-
143
- it("shoud return server config value", function (done) {
144
- var self = this;
145
- this.client.config("log/level", function (err, body, status, headers, res) {
146
- if (!err) {
147
- expect(body).to.be.a("string");
148
- shared.shouldHave2xxStatus(status);
149
- self.value = body;
150
- }
151
- done(err);
152
- });
153
- });
154
-
155
- it("shoud set server config value", function (done) {
156
- this.client.config("log/level", this.value, function (err, body, status, headers, res) {
157
- if (!err) {
158
- shared.shouldHave2xxStatus(status);
159
- }
160
- done(err);
161
- });
162
- });
163
-
164
- });
165
-
166
- describe("#replicate", function () {
167
-
168
- before(function () {
169
- this.replica = this.client.db(this.dbname + "-client-replica");
170
- });
171
-
172
- before(shared.createDB("db"));
173
- before(shared.createDB("replica"));
174
- after(shared.destroyDB("db"));
175
- after(shared.destroyDB("replica"));
176
-
177
- it("shoud be ok", function (done) {
178
- var options = {
179
- source: this.db.name,
180
- target: this.replica.name
181
- };
182
- this.client.replicate(options, function (err, body, status, headers, res) {
183
- if (!err) {
184
- shared.shouldBeOk(body);
185
- shared.shouldHave2xxStatus(status);
186
- }
187
- done(err);
188
- });
189
- });
190
-
191
- });
192
-
193
- });