Node.js Mock N1QL Query Support


#1

Hi,

I’m reasonably new to Couchbase and I’m using the provided Mock for my unit tests.

cluster = new couchbase.Mock.Cluster();

Is there any planned support for N1QL in the Mock object?

Error: N1QL queries are not supported in the mock.
      at MockBucket.query (node_modules/couchbase/lib/mock/bucket.js:888:11)
      at Object.findUser (dist/lib/rpc/user/find.js:9:311)
      at Context.<anonymous> (dist/lib/rpc/user/find_spec.js:9:28)
      at Test.Runnable.run (node_modules/co-mocha/lib/co-mocha.js:43:16)

Without N1QL support in the Mock some tests will now have run against a live test instance.

The only real issue with that is when I flush the bucket before the test suite runs it adds quite a bit of time, about 8-9 seconds, to my application test suite.

Using Mock = <2 sec

No Mock ~9 sec


#2

Maybe I posted too soon.

One option that works fine for me to stub out the N1QL query with sinonjs

I can create a test fixture from a real couchbase instance, then use that in my tests and continue to use the Mock object (for speed).

I’ll rig up an environment flag for my tests to toggle Mock or Live database.