Skip to content

Commit

Permalink
Randomize test database name and update tests to support changing the…
Browse files Browse the repository at this point in the history
… target CouchDB host and authentication.
  • Loading branch information
mikepb committed Feb 5, 2015
1 parent c364489 commit a7c50eb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions test/client_test.js
Expand Up @@ -13,7 +13,9 @@ describe("Client", function () {
describe("#db", function () {
it("should return DB object", function () {
expect(this.db).to.be.a(clerk.DB);
expect(this.db).to.have.property("uri", "http://127.0.0.1:5984/clerk-test");
var uri = this.baseURL.replace(/^(https?:\/\/)([^@\/]+@)/, "$1") + "/" +
this.dbname;
expect(this.db).to.have.property("uri", uri);
});
});

Expand Down Expand Up @@ -205,7 +207,7 @@ describe("Client", function () {
describe("#replicate", function () {

beforeEach(function () {
this.db = this.client.db("clerk-test");
this.db = this.client.db(this.dbname);
this.replica = this.client.db("clerk-replicate-test");
});

Expand Down
3 changes: 2 additions & 1 deletion test/database_test.js
Expand Up @@ -86,9 +86,10 @@ describe("DB", function () {

describe("#info", function () {
it("should return database info", function (done) {
var self = this;
this.db.info(function (err, body, status, headers, res) {
if (!err) {
expect(body).to.have.property("db_name", "clerk-test");
expect(body).to.have.property("db_name", self.dbname);
expect(body).to.have.property("doc_count", 0);
expect(body).to.have.property("doc_del_count", 0);
shared.shouldHave2xxStatus(status);
Expand Down
6 changes: 4 additions & 2 deletions test/shared.js
Expand Up @@ -6,8 +6,10 @@ var clerk = require(browser ? "../lib/clerk" : "../index");
var expect = require("expect.js");

exports.clerkFactory = function () {
this.client = clerk("http://127.0.0.1:5984");
this.db = this.client.db("clerk-test");
this.baseURL = "http://127.0.0.1:5984";
this.dbname = "clerk-test-" + (1000 * Math.random() | 0);
this.client = clerk(this.baseURL);
this.db = this.client.db(this.dbname);
};

exports.docFactory = function () {
Expand Down

0 comments on commit a7c50eb

Please sign in to comment.