forked from zdzolton/couch-cover
/
README
48 lines (36 loc) · 1.23 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
CouchCover
==========
A mock environment for using Node.js to test CouchDB design document functions.
Usage
=====
# Forgive the Coffee-colored syntax...
CouchCover = require 'CouchCover'
assert = require 'assert'
# Let's load up the design doc!
ddoc = new CouchCover.DesignDoc {
foo: '''
function(s) {
return "From foo: " + s "!";
}
'''
}
# Now, let's call function 'foo' with argument 'bar':
retVal = ddoc.call 'foo', ['bar']
# And note the return value
assert.equal 'From foo: bar!', retVal
# You can also get a reference, and call that:
fooFun = ddoc.compile 'foo'
retVal = fooFun.call 'bar'
# And note the return value
assert.equal 'From foo: bar!', retVal
Dependencies
============
There are currently no run-time dependencies, but you do need CoffeeScript to hack this package.
TODOs
=====
* Show usage of require() and log() functions from ddoc code
* CouchFunction subtypes for List, Show, Validation and Filter functions
* API documentation
* Ensure that show, list, update and validation functions cannot call
require() with a relative path
* Ensure that view map/reduce functions cannot call require whatsoever