Skip to content

Commit 60b656d

Browse files
authored
Merge pull request #230 from wareczek/expected-3-arguments
fix bug "expected 3 arguments"
2 parents 4ee9441 + 6aa5d86 commit 60b656d

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Check out the code in the [examples](./examples) folder: master,workers, tasks a
132132
* (note the trailing `_`)
133133
* `a_set_acl(path, version, acl, void_cb)`
134134
* `a_get_acl(path, acl_cb)`
135-
* `add_auth(scheme, auth)`
135+
* `add_auth(scheme, auth, void_cb)`
136136

137137
*The watcher methods are forward-looking subscriptions that can recieve multiple callbacks whenever a matching event occurs.*
138138

lib/zookeeper.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,12 @@ class ZooKeeper extends EventEmitter {
328328
/**
329329
* @param scheme {string}
330330
* @param auth {string}
331+
* @param voidCb {voidCb}
331332
* @returns {*}
332333
*/
333-
add_auth(scheme, auth) {
334-
this.log(`Calling add_auth with ${util.inspect([scheme, auth])}`);
335-
return this.native.add_auth(scheme, auth);
334+
add_auth(scheme, auth, voidCb) {
335+
this.log(`Calling add_auth with ${util.inspect([scheme, auth, voidCb])}`);
336+
return this.native.add_auth(scheme, auth, voidCb);
336337
}
337338

338339
/**

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@
5151
"build-components": "node-gyp configure build --directory=tests/components",
5252
"install": "node ./scripts/prepublish.js && npm run build",
5353
"lint": "eslint .",
54-
"test": "npm run lint && tape ./tests/unit/**/*.js | tap-spec",
54+
"test": "npm run lint && npm run test-unit",
5555
"test-components": "npm run build-components && tape ./tests/components/**/*.js | tap-spec",
56-
"test-integration": "node ./tests/integration/index"
56+
"test-integration": "node ./tests/integration/index",
57+
"test-unit": "tape ./tests/unit/**/*.js | tap-spec"
5758
},
5859
"engines": {
5960
"node": ">=8.9.4"

tests/unit/zookeeper/nativeobjecttest.js

+10
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,13 @@ test('native object emits close and pass an instance of the current ZooKeeper',
5757

5858
zk.native.emit('close', 1, 2, 3);
5959
});
60+
61+
test('native zookeeper add_auth', (t) => {
62+
t.plan(3);
63+
64+
const zk = new ZooKeeper({});
65+
66+
t.throws(() => zk.native.add_auth('digest'), 'expected 3 arguments');
67+
t.throws(() => zk.native.add_auth('digest', 'user:'), 'expected 3 arguments');
68+
t.doesNotThrow(() => zk.native.add_auth('digest', 'user:', () => {}), 'expected 3 arguments');
69+
});

0 commit comments

Comments
 (0)