restify/clients

assert-plus@1.0.0 update in v1.3.2 broke calling JSONCLIENT.post without a body argument

trentm opened this issue · 1 comments

Adding this test to ensure <jsonclient>.post(...) without passing a body
argument works (as it does with node-restify.git/lib/clients/json_client.js).

diff --git a/test/index.js b/test/index.js
index 95579d0..e5ee8bf 100644
--- a/test/index.js
+++ b/test/index.js
@@ -356,6 +356,16 @@ describe('restify-client tests', function () {
         });
     });

+    it('POST json without body arg', function (done) {
+        JSON_CLIENT.post('/json/mcavage', function (err, req, res, obj) {
+            assert.ifError(err);
+            assert.ok(req);
+            assert.ok(res);
+            assert.deepEqual(obj, {hello: 'mcavage'});
+            done();
+        });
+    });
+

     it('PUT json', function (done) {
         var data = { hello: 'foo' };

This fails:

$ make test
...
  restify-client tests
...
    ✓ HEAD json
    ✓ POST json
    ✓ POST json empty body object
    1) POST json without body arg
    ✓ PUT json
    ✓ PATCH json
...


  134 passing (3s)
  1 failing

  1) restify-client tests POST json without body arg:

      AssertionError: body (object) is required
      + expected - actual


      at JsonClient.write (/Users/trentm/tm/restify-clients/lib/JsonClient.js:34:12)
      at JsonClient.post (/Users/trentm/tm/restify-clients/lib/StringClient.js:64:18)
      at Context.<anonymous> (/Users/trentm/tm/restify-clients/test/index.js:360:21)
      at callFnAsync (/Users/trentm/tm/restify-clients/node_modules/mocha/lib/runnable.js:349:8)
      at Test.Runnable.run (/Users/trentm/tm/restify-clients/node_modules/mocha/lib/runnable.js:301:7)
      at Runner.runTest (/Users/trentm/tm/restify-clients/node_modules/mocha/lib/runner.js:422:10)
      at /Users/trentm/tm/restify-clients/node_modules/mocha/lib/runner.js:528:12
      at next (/Users/trentm/tm/restify-clients/node_modules/mocha/lib/runner.js:342:14)
      at /Users/trentm/tm/restify-clients/node_modules/mocha/lib/runner.js:352:7
      at next (/Users/trentm/tm/restify-clients/node_modules/mocha/lib/runner.js:284:14)
      at Immediate._onImmediate (/Users/trentm/tm/restify-clients/node_modules/mocha/lib/runner.js:320:5)
      at processImmediate [as _immediateCallback] (timers.js:383:17)



make: *** [test] Error 1

The issue is this assert.object call:
https://github.com/trentm/clients/blob/7a90b56a04442fb1fadbceb602ff2a2f3e777177/lib/JsonClient.js#L34

In restify-clients@1.3.2 the assert-plus dependency was updated from
0.1.5 to 1.0.0. One thing was missed in that update, from the assert-plus
changelog:

...
## 0.2.0

- Fix `assert.object(null)` so it throws
...

Notably node-restify.git#4.x still uses assert-plus@0.1.5 so it doesn't hit
this issue.

restify-clients@1.4.1 published with this fix