Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Kouch.prototype.connect = function (dsn, buckets, cb, mock) {
if (mock) {
this.cluster = new couchbase.Mock.Cluster(dsn);
}
else {
this.cluster = new couchbase.Cluster(dsn);
}
// nothing passed, assume they want the default bucket
if (!buckets) {
buckets = { name: 'default' };
}
// string bucket name passed, parse into object
else if (typeof buckets === 'string') {
buckets = { name: buckets };
}
// catch the case of something strange being passed in...
describe('#Mock', () => {
const mock = couchbase.Mock;
const nmock = nativeCouch.Mock;
describe('#N1qlQuery', () => {
it('should reference native couchbase.N1qlQuery', (done) => {
assert.strictEqual(mock.N1qlQuery, nmock.N1qlQuery);
done();
});
});
describe('#SpatialQuery', () => {
it('should reference native couchbase.SpatialQuery', (done) => {
assert.strictEqual(mock.SpatialQuery, nmock.SpatialQuery);
done();
});
});
describe('#ViewQuery', () => {
it('should reference native couchbase.ViewQuery', (done) => {
exports.getCluser = function () {
return process.env.LOUNGE_COUCHBASE_MOCK
? new couchbase.Mock.Cluster('couchbase://127.0.0.1')
: new couchbase.Cluster('couchbase://127.0.0.1')
}
'use strict';
const couchbase = require('couchbase');
const elv = require('elv');
const Bucket = require('./bucket');
const Cluster = require('./cluster');
const promises = require('./promises');
const Mock = {
Cluster: require('./mock-cluster'),
SpatialQuery: couchbase.Mock.SpatialQuery,
ViewQuery: couchbase.Mock.ViewQuery,
N1qlQuery: couchbase.Mock.N1qlQuery,
Mock: null,
Error: couchbase.Mock.Error,
errors: couchbase.Mock.errors
};
Mock.Mock = Mock;
class Couchbase {
static get Cluster() { return Cluster; }
static get SpatialQuery() { return couchbase.SpatialQuery; }
static get ViewQuery() { return couchbase.ViewQuery; }
static get N1qlQuery() { return couchbase.N1qlQuery; }
static get CbasQuery() { return couchbase.CbasQuery; }
'use strict';
const couchbase = require('couchbase');
const elv = require('elv');
const Bucket = require('./bucket');
const Cluster = require('./cluster');
const promises = require('./promises');
const Mock = {
Cluster: require('./mock-cluster'),
SpatialQuery: couchbase.Mock.SpatialQuery,
ViewQuery: couchbase.Mock.ViewQuery,
N1qlQuery: couchbase.Mock.N1qlQuery,
Mock: null,
Error: couchbase.Mock.Error,
errors: couchbase.Mock.errors
};
Mock.Mock = Mock;
class Couchbase {
static get Cluster() { return Cluster; }
static get SpatialQuery() { return couchbase.SpatialQuery; }
static get ViewQuery() { return couchbase.ViewQuery; }
static get N1qlQuery() { return couchbase.N1qlQuery; }
static get CbasQuery() { return couchbase.CbasQuery; }
static get SearchQuery() { return couchbase.SearchQuery; }
debug(`connect to open bucket`)
this.bucket = options.bucket
if (this.bucket) {
this.db = Driver.create(this.bucket, this.config)
}
process.nextTick(() => retFn(null, this.bucket))
} else if (options.bucket && typeof options.bucket === 'string' &&
options.connectionString && typeof options.connectionString === 'string') {
debug(`connect. cluster: ${options.connectionString} bucket: ${options.bucket}`)
const clusterOpts = options.certpath ? {
certpath: options.certpath
} : null
const ClusterCtor = options.mock || process.env.LOUNGE_COUCHBASE_MOCK ? couchbase.Mock.Cluster : couchbase.Cluster
let args = typeof options.password === 'string'
? [options.bucket, options.password, retFn]
: [options.bucket, retFn]
const cluster = new ClusterCtor(options.connectionString, clusterOpts)
if (typeof cluster.authenticate === 'function' && options.username) {
cluster.authenticate(options.username, options.password)
args = [options.bucket, retFn]
}
this.bucket = cluster.openBucket(...args)
}
}
constructor(cnstr) {
const native = new couchbase.Mock.Cluster(cnstr);
native.authenticate = function(auther) {};
native.query = function(query, params, callback) {
process.nextTick(() => {
callback(null, true);
});
}
state.set(this, native);
}