chris-l / mock-couch

A node.js module designed to mock a CouchDB server, mostly for unit testing purposes.
http://chris-l.github.io/mock-couch/
67 stars 44 forks source link

updated spec and get_view to allow for views inserted as strings to r… #46

Closed thedewpoint closed 8 years ago

thedewpoint commented 8 years ago

A popular module couchviews is used to dump the views from an existing couch database and save them as a json file, this is then reimported using the same module into a new couch database (in this case mock-couch). This works on a real instance of couchdb, but on mock couch because it was inserted from a json string, the map function is unable to run. I've updated the spec and the code to allow for integration with this module

chris-l commented 8 years ago

Ah yes, I know couchviews, but I never tried to use it with mock-couch before. Thanks for highlighting this problem!

However, I've just accepted a PR that used the function constructor to convert the strings with functions inside _design docs that were uploaded with POST/PUT to actual functions and then stored that, instead of storing them as strings and then using eval at execution time on them.

Therefore, in order to be consistent, instead of using this PR, I changed the conversion method, so it would be used on the function that handles _bulk_docs.

Also, after trying to use couchviews on mock-couch, I realized that couchviews was using _all_docs and failing, for a bug related to how it handles the keys property. So, I also fixed that.

Now, the current version seems to be working fine with couchviews. (at least on my tests; if you find a problem, feel free to open another issue)

Thanks!

thedewpoint commented 8 years ago

Awesome thanks for your help On Jul 1, 2016 5:52 AM, "christopher luna" notifications@github.com wrote:

Closed #46 https://github.com/chris-l/mock-couch/pull/46.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chris-l/mock-couch/pull/46#event-710294807, or mute the thread https://github.com/notifications/unsubscribe/ADEBQ0wlI8n7UFcQj92g4kxsfwL40Gqmks5qRONTgaJpZM4JCs3W .