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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
292 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
*tmp.* | ||
*.log | ||
node_modules/ | ||
node_modules/ | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"boss": true, | ||
"node": true, | ||
"strict": true, | ||
"smarttabs": true, | ||
"maxlen": 80, | ||
"newcap": false, | ||
"undef": true, | ||
"unused": true, | ||
"onecase": true, | ||
"indent": 2, | ||
"sub": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,32 @@ | ||
var specify = require('specify') | ||
, helpers = require('../helpers') | ||
, timeout = helpers.timeout | ||
, nano = helpers.nano | ||
, nock = helpers.nock | ||
; | ||
'use strict'; | ||
|
||
var mock = nock(helpers.couch, "att/destroy") | ||
, db = nano.use("att_destroy") | ||
; | ||
var helpers = require('../helpers'); | ||
var harness = helpers.harness(); | ||
var it = harness.it; | ||
|
||
specify("att_destroy:setup", timeout, function (assert) { | ||
nano.db.create("att_destroy", function (err) { | ||
assert.equal(err, undefined, "Failed to create database"); | ||
}); | ||
}); | ||
|
||
specify("att_destroy:test", timeout, function (assert) { | ||
db.attachment.insert("new", "att", "Hello World!", "text/plain", | ||
function (error, att) { | ||
assert.equal(error, undefined, "Should store the attachment"); | ||
assert.equal(att.ok, true, "Response should be ok"); | ||
assert.ok(att.rev, "Should have a revision number"); | ||
db.attachment.destroy("new", "att", att.rev, function(error, response) { | ||
assert.equal(error, undefined, "Should delete the attachment"); | ||
assert.equal(response.ok, true, "Response should be ok"); | ||
assert.equal(response.id, "new", "Id should be new"); | ||
}); | ||
}); | ||
}); | ||
|
||
specify("att_destroy:att_name_missing", timeout, function (assert) { | ||
db.attachment.insert("new2", "att2", "Hello World!", "text/plain", | ||
function (error, att) { | ||
assert.equal(error, undefined, "Should store the attachment"); | ||
assert.equal(att.ok, true, "Response should be ok"); | ||
assert.ok(att.rev, "Should have a revision number"); | ||
db.attachment.destroy("new", false, att.rev, function(error, response) { | ||
assert.equal(error.errid, "bad_params", "Should throw error because att_name is not a string"); | ||
assert.equal(response, undefined, "No response should be given"); | ||
it('should be able to insert a new plain text attachment', function(assert) { | ||
var locals = this; | ||
locals.db.attachment.insert('new', | ||
'att', 'Hello World!', 'text/plain', function(error, att) { | ||
assert.equal(error, null, 'store the attachment'); | ||
assert.equal(att.ok, true, 'response ok'); | ||
assert.ok(att.rev, 'have a revision number'); | ||
locals.db.attachment.destroy('new', 'att', | ||
att.rev, function(error, response) { | ||
assert.equal(error, null, 'delete the attachment'); | ||
assert.equal(response.ok, true, 'response ok'); | ||
assert.equal(response.id, 'new', '`id` should be `new`'); | ||
assert.end(); | ||
}); | ||
}); | ||
}); | ||
|
||
specify("att_destroy:teardown", timeout, function (assert) { | ||
nano.db.destroy("att_destroy", function (err) { | ||
assert.equal(err, undefined, "Failed to destroy database"); | ||
assert.ok(mock.isDone(), "Some mocks didn't run"); | ||
it('should fail destroying with a bad filename', function(assert) { | ||
var locals = this; | ||
locals.db.attachment.destroy('new', false, true, function(error, response) { | ||
assert.equal(error.errid, 'bad_params', | ||
'`att_name` should be a string'); | ||
assert.equal(response, undefined, 'no response should be given'); | ||
assert.end(); | ||
}); | ||
}); | ||
|
||
specify.run(process.argv.slice(2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,37 @@ | ||
var specify = require('specify') | ||
, helpers = require('../helpers') | ||
, timeout = helpers.timeout | ||
, nano = helpers.nano | ||
, nock = helpers.nock | ||
; | ||
'use strict'; | ||
|
||
var mock = nock(helpers.couch, "att/get") | ||
, db = nano.use("att_get") | ||
; | ||
var helpers = require('../helpers'); | ||
var harness = helpers.harness(); | ||
var it = harness.it; | ||
|
||
|
||
specify("att_get:setup", timeout, function (assert) { | ||
nano.db.create("att_get", function (err) { | ||
assert.equal(err, undefined, "Failed to create database"); | ||
}); | ||
}); | ||
|
||
specify("att_get:test_string", timeout, function (assert) { | ||
db.attachment.insert("new_string", "att", "Hello", "text/plain", | ||
it('should be able to fetch an attachment', function(assert) { | ||
var locals = this; | ||
locals.db.attachment.insert('new_string', 'att', 'Hello', 'text/plain', | ||
function(error, hello) { | ||
assert.equal(error, undefined, "Should store hello"); | ||
assert.equal(hello.ok, true, "Response should be ok"); | ||
assert.ok(hello.rev, "Should have a revision number"); | ||
db.attachment.get("new_string", "att", | ||
function (error, helloWorld) { | ||
assert.equal(error, undefined, "Should get the hello"); | ||
assert.equal("Hello", helloWorld, "string is reflexive"); | ||
assert.equal(error, null, 'should store `hello`'); | ||
assert.equal(hello.ok, true, 'response ok'); | ||
assert.ok(hello.rev, 'should have a revision number'); | ||
locals.db.attachment.get('new_string', 'att', | ||
function(error, helloWorld) { | ||
assert.equal(error, null, 'should get `hello`'); | ||
assert.equal('Hello', helloWorld.toString(), 'string is reflexive'); | ||
assert.end(); | ||
}); | ||
}); | ||
}); | ||
|
||
specify("att_get:test_binary", timeout, function (assert) { | ||
db.attachment.insert("new_binary", "att", new Buffer("123"), "text/plain", | ||
function(error, hello) { | ||
assert.equal(error, undefined, "Should store 123"); | ||
assert.equal(hello.ok, true, "Response should be ok"); | ||
assert.ok(hello.rev, "Should have a revision number"); | ||
db.attachment.get("new_binary", "att", | ||
function (error, binaryData) { | ||
assert.equal(error, undefined, "Should get the binary data"); | ||
assert.equal("123", binaryData, "binary data is reflexive"); | ||
it('should insert and fetch a binary file', function(assert) { | ||
var locals = this; | ||
locals.db.attachment.insert('new_binary', 'att', | ||
new Buffer('123'), 'text/plain', function(error, hello) { | ||
assert.equal(error, null, 'should store `123`'); | ||
assert.equal(hello.ok, true, 'response ok'); | ||
assert.ok(hello.rev, 'should have a revision number'); | ||
locals.db.attachment.get('new_binary', 'att', | ||
function(error, binaryData) { | ||
assert.equal(error, null, 'should get the binary data'); | ||
assert.equal('123', binaryData.toString(), 'binary data is reflexive'); | ||
assert.end(); | ||
}); | ||
}); | ||
}); | ||
|
||
specify("att_get:teardown", timeout, function (assert) { | ||
nano.db.destroy("att_get", 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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,15 @@ | ||
var specify = require('specify') | ||
, helpers = require('../helpers') | ||
, timeout = helpers.timeout | ||
, nano = helpers.nano | ||
, nock = helpers.nock | ||
; | ||
|
||
var mock = nock(helpers.couch, "att/insert") | ||
, db = nano.use("att_insert") | ||
; | ||
|
||
specify("att_insert:setup", timeout, function (assert) { | ||
nano.db.create("att_insert", function (err) { | ||
assert.equal(err, undefined, "Failed to create database"); | ||
}); | ||
}); | ||
|
||
specify("att_insert:test", timeout, function (assert) { | ||
db.attachment.insert("new", "att", "Hello World!", "text/plain", | ||
function (error, att) { | ||
assert.equal(error, undefined, "Should store the attachment"); | ||
assert.equal(att.ok, true, "Response should be ok"); | ||
assert.ok(att.rev, "Should have a revision number"); | ||
'use strict'; | ||
|
||
var helpers = require('../helpers'); | ||
var harness = helpers.harness(); | ||
var it = harness.it; | ||
|
||
it('should be able to insert a simple attachment', function(assert) { | ||
this.db.attachment.insert('new', 'att', 'Hello World!', 'text/plain', | ||
function(error, att) { | ||
assert.equal(error, null, 'should store the attachment'); | ||
assert.equal(att.ok, true, 'response ok'); | ||
assert.ok(att.rev, 'should have a revision'); | ||
assert.end(); | ||
}); | ||
}); | ||
|
||
specify("att_insert:teardown", timeout, function (assert) { | ||
nano.db.destroy("att_insert", 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)); |
Oops, something went wrong.