Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Commit

Permalink
Added tests for db.head(doc_id, cb)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleics committed May 20, 2012
1 parent 56cfa6a commit 6324124
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/doc/head.js
@@ -0,0 +1,46 @@
var specify = require("specify")
, helpers = require("../helpers")
, timeout = helpers.timeout
, nano = helpers.nano
, nock = helpers.nock
;

var mock = nock(helpers.couch, "doc/head")
, db = nano.use("doc_head")
, rev
;

specify("doc_head:setup", timeout, function (assert) {
nano.db.create("doc_head", function (err) {
assert.equal(err, undefined, "Failed to create database");
db.insert({"foo": "baz"}, "foobaz", function (error, foo) {
assert.equal(error, undefined, "Should have stored foobaz");
assert.equal(foo.ok, true, "Response should be ok");
assert.equal(foo.id, "foobaz", "My id is foobaz");
assert.ok(foo.rev, "Response should have rev");
rev = foo.rev;
});
});
});

specify("doc_head:test", timeout, function (assert) {
db.insert({"foo": "bar"}, "foobaz", function (error, response) {
assert.equal(error["status-code"], 409, "Should be conflict");
assert.equal(error.scope, "couch", "Scope is couch");
assert.equal(error.error, "conflict", "Error is conflict");
db.head("foobaz", function (error, body, h) {
assert.equal(error, undefined, "Should get the head of foobaz");
assert.equal(body, undefined, "Should have no body");
assert.equal(h["status-code"], 200, "Should be ok");
});
});
});

specify("doc_head:teardown", timeout, function (assert) {
nano.db.destroy("doc_head", function (err) {
assert.equal(err, undefined, "Failed to destroy database");
assert.ok(mock.isDone(), "Some mocks didn't run");
});
});

specify.run(process.argv.slice(2));

0 comments on commit 6324124

Please sign in to comment.