Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## 4.0

### 4.4.0
* __New Features__
+ Adding new methods to `ClusterManager`
- Adding method `ClusterManager.prototype.getUser()`
- Adding method `ClusterManager.prototype.getUserAsync()`
- Adding method `ClusterManager.prototype.getUsers()`
- Adding method `ClusterManager.prototype.getUsersAsync()`
- Adding method `ClusterManager.prototype.removeUser()`
- Adding method `ClusterManager.prototype.removeUserAsync()`
- Adding method `ClusterManager.prototype.upsertUser()`
- Adding method `ClusterManager.prototype.upsertUserAsync()`

### 4.3.0
+ Updating `couchbase` version to 2.4.0.

Expand Down
64 changes: 64 additions & 0 deletions lib/clustermgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,38 @@ class ClusterManager {
}
}

if (typeof clustermgr.getUsers !== 'function') {
clustermgr.getUsers = function(domain, callback) {
process.nextTick(() => {
callback(null, true);
})
}
}

if (typeof clustermgr.getUser !== 'function') {
clustermgr.getUser = function(domain, userid, callback) {
process.nextTick(() => {
callback(null, true);
})
}
}

if (typeof clustermgr.removeUser !== 'function') {
clustermgr.removeUser = function(domain, userid, callback) {
process.nextTick(() => {
callback(null, true);
})
}
}

if (typeof clustermgr.upsertUser !== 'function') {
clustermgr.upsertUser = function(domain, userid, settings, callback) {
process.nextTick(() => {
callback(null, true);
})
}
}

state.set(this, clustermgr);
}

Expand All @@ -60,6 +92,38 @@ class ClusterManager {
removeBucketAsync(name) {
return promisify.call(this, this.removeBucket, name);
}

getUser(domain, userid, callback) {
return me(this).getUser(domain, userid, callback);
}

getUserAsync(domain, userid) {
return promisify.call(this, this.getUser, domain, userid);
}

getUsers(domain, callback) {
return me(this).getUsers(domain, callback);
}

getUsersAsync(domain) {
return promisify.call(this, this.getUsers, domain);
}

removeUser(domain, userid, callback) {
return me(this).removeUser(domain, userid, callback);
}

removeUserAsync(domain, userid) {
return promisify.call(this, this.removeUser, domain, userid);
}

upsertUser(domain, userid, settings, callback) {
return me(this).upsertUser(domain, userid, settings, callback);
}

upsertUserAsync(domain, userid, settings) {
return promisify.call(this, this.upsertUser, domain, userid, settings);
}
}

module.exports = ClusterManager;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "couchbase-promises",
"longName": "Couchbase Promises",
"description": "An A+ Promises wrapper for the Couchbase SDK with added support for batch mutation operations.",
"version": "4.3.0",
"version": "4.4.0",

"dependencies": {
"bluebird": "^3.5.0",
Expand Down
104 changes: 104 additions & 0 deletions tests/unit/clustermgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,109 @@ function test(library, libraryName) {
});
});
});

describe('#getUsers', () => {
it('should execute', (done) => {
mgr.getUsers('test', (err, res) => {
assert.isNotOk(err);
assert.isOk(res);
done();
});
});
});

describe('#getUsersAsync', () => {
it('should return a Promise', (done) => {
const result = mgr.getUsersAsync('test');
assert.instanceOf(result, couchbase.Promise);
done();
});

it('should execute', (done) => {
mgr.getUsersAsync('test')
.then((res) => {
assert.isOk(res);
done();
});
});
});

describe('#getUser', () => {
it('should execute', (done) => {
mgr.getUser('test', 'test', (err, res) => {
assert.isNotOk(err);
assert.isOk(res);
done();
});
});
});

describe('#getUserAsync', () => {
it('should return a Promise', (done) => {
const result = mgr.getUserAsync('test', 'test');
assert.instanceOf(result, couchbase.Promise);
done();
});

it('should execute', (done) => {
mgr.getUserAsync('test', 'test')
.then((res) => {
assert.isOk(res);
done();
});
});
});

describe('#removeUser', () => {
it('should execute', (done) => {
mgr.removeUser('test', 'test', (err, res) => {
assert.isNotOk(err);
assert.isOk(res);
done();
});
});
});

describe('#removeUserAsync', () => {
it('should return a Promise', (done) => {
const result = mgr.removeUserAsync('test', 'test');
assert.instanceOf(result, couchbase.Promise);
done();
});

it('should execute', (done) => {
mgr.removeUserAsync('test', 'test')
.then((res) => {
assert.isOk(res);
done();
});
});
});

describe('#upsertUser', () => {
it('should execute', (done) => {
mgr.upsertUser('test', 'test', {}, (err, res) => {
assert.isNotOk(err);
assert.isOk(res);
done();
});
});
});

describe('#upsertUserAsync', () => {
it('should return a Promise', (done) => {
const result = mgr.upsertUserAsync('test', 'test', {});
assert.instanceOf(result, couchbase.Promise);
done();
});

it('should execute', (done) => {
mgr.upsertUserAsync('test', 'test', {})
.then((res) => {
assert.isOk(res);
done();
});
});
});
});
}