v2.0.0 mock Node.js implementation of insert ddoc falsely reports ddoc already exists

When inserting a new design document via the Mock backup manager (this method: https://github.com/couchbase/couchnode/blob/master/lib/mock/bucketmgr.js#L14), the logic at this line is incorrectly determining that the design document already exists: https://github.com/couchbase/couchnode/blob/master/lib/mock/bucketmgr.js#L17

I believe the logic should look something like this:

Steps to reproduce:

  1. use the official v2.0.0 Node.js module.
  2. start with an empty database or one with no views in it at least.
  3. create a Node.js app that connects to couchbase using the mock implementation.
  4. insert a design document via the bucket manager.
  5. observe that you get an error telling you that the design document exists, when of course it doesn’t.

Would be great to know if this fix is correct and have it merged into the official module.

(Node.js API v2.0.0.)

Hey Guys, should probably fix getDesignDocument to throw an error if the document was not found. Move the test fix to that function instead and generate an error if it fails.

I have opened an issue to track this (https://www.couchbase.com/issues/browse/JSCBC-151) and will fix it for the next release!

Cheers, Brett

Note that the ticket has now been updated with an attached fix.

Cheers, Brett

Still have the same error when the view does not exist.

I have sent a pull request which seems to fix the bug: https://github.com/veacks/couchnode/commit/2a2b8ad9e9edd0fea8132b7da5779a6eff91ab74#diff-db5d39aa24dc412099428f7720894dc0R17

Cheers, Val