Skip to content

Provides a mock evironment for testing CouchDB design document functions

License

Notifications You must be signed in to change notification settings

zdzolton/couch-cover

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Provides a mock evironment for testing CouchDB design document functions

Resources

License

Stars

Watchers

Forks

Packages

No packages published