This repository has been archived by the owner on Nov 5, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- allows easy querying of show functions
- Loading branch information
Showing
4 changed files
with
129 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[ | ||
{ "method" : "put" | ||
, "path" : "/show_query" | ||
, "status" : 201 | ||
, "response" : "{ \"ok\": true }" | ||
} | ||
, { "method" : "put" | ||
, "path" : "/show_query/_design/people" | ||
, "body" : "{\"shows\":{\"singleDoc\":\"function (doc, req) { return { body: { name: doc.name, city: doc.city, format: 'json' }, headers: { 'Content-Type': 'application/json' } }; }\"}}" | ||
, "status" : 201 | ||
, "response" : "{\"ok\":true,\"id\":\"_design/people\",\"rev\":\"1-14e6bc\"}" | ||
} | ||
, { "method" : "put" | ||
, "status" : 201 | ||
, "path" : "/show_query/p_clemens" | ||
, "body" : "{\"name\":\"Clemens\",\"city\":\"Dresden\"}" | ||
, "response" : "{\"ok\":true,\"id\":\"p_clemens\",\"rev\":\"1-4c6114\"}" | ||
} | ||
, { "method" : "put" | ||
, "status" : 201 | ||
, "path" : "/show_query/p_randall" | ||
, "body" : "{\"name\":\"Randall\",\"city\":\"San Francisco\"}" | ||
, "response" : "{\"ok\":true,\"id\":\"p_randall\",\"rev\":\"1-4c6114\"}" | ||
} | ||
, { "method" : "put" | ||
, "status" : 201 | ||
, "path" : "/show_query/p_nuno" | ||
, "body" : "{\"name\":\"Nuno\",\"city\":\"New York\"}" | ||
, "response" : "{\"ok\":true,\"id\":\"p_nuno\",\"rev\":\"1-4c6114\"}" | ||
} | ||
, { "path" : "/show_query/_design/people/_show/singleDoc/p_clemens" | ||
, "response" : "{\"name\":\"Clemens\",\"city\":\"Dresden\",\"format\":\"json\"}\n" | ||
} | ||
, { "method" : "delete" | ||
, "path" : "/show_query" | ||
, "status" : 200 | ||
, "response" : "{ \"ok\": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var specify = require('specify') | ||
, async = require('async') | ||
, helpers = require('../helpers') | ||
, timeout = helpers.timeout | ||
, nano = helpers.nano | ||
, nock = helpers.nock | ||
; | ||
|
||
var mock = nock(helpers.couch, "show/query") | ||
, db = nano.use("show_query") | ||
; | ||
|
||
specify("show_query:setup", timeout, function (assert) { | ||
nano.db.create("show_query", function (err) { | ||
assert.equal(err, undefined, "Failed to create database"); | ||
db.insert( | ||
{ "shows": { | ||
"singleDoc": function(doc, req) { return { body: { name: doc.name, city: doc.city, format: 'json' }, headers: { 'Content-Type': 'application/json' } }; } | ||
} | ||
}, '_design/people', function (error, response) { | ||
assert.equal(error, undefined, "Failed to create show function"); | ||
assert.equal(response.ok, true, "Response should be ok"); | ||
async.parallel( | ||
[ function(cb) { db.insert( | ||
{ name: "Clemens", city: "Dresden" }, "p_clemens", cb); } | ||
, function(cb) { db.insert( | ||
{ name: "Randall", city: "San Francisco" }, "p_randall", cb); } | ||
, function(cb) { db.insert( | ||
{ name: "Nuno", city: "New York" }, "p_nuno", cb); } | ||
] | ||
, function(error, results) { | ||
assert.equal(error, undefined, "Should have stored docs"); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
specify("show_query:test", timeout, function (assert) { | ||
db.show('people','singleDoc', 'p_clemens', function (error, doc) { | ||
assert.equal(error, undefined, "Show function didn't respond"); | ||
assert.equal(doc.name,'Clemens'); | ||
assert.equal(doc.city,'Dresden'); | ||
assert.equal(doc.format,'json'); | ||
}); | ||
}); | ||
|
||
specify("show_query:teardown", timeout, function (assert) { | ||
nano.db.destroy("show_query", 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)); |