diff --git a/lib/gearmanode/version.js b/lib/gearmanode/version.js index d12ad1b..64572e4 100644 --- a/lib/gearmanode/version.js +++ b/lib/gearmanode/version.js @@ -19,7 +19,7 @@ exports.VERSION_HISTORY = [ - ['0.9.2', '2015-12-22', 'PR #41'], + ['0.9.2', '2015-12-21', 'PR #41'], ['0.9.1', '2015-06-28', 'PR #35, Enh #24'], ['0.9.0', '2015-06-19', 'PR #29, fully implemented Gearman Protocol'], ['0.2.2', '2015-02-04', 'BF #26'], diff --git a/test/test-job-server.js b/test/test-job-server.js index 1798af7..26b4390 100644 --- a/test/test-job-server.js +++ b/test/test-job-server.js @@ -245,7 +245,6 @@ describe('JobServer', function() { var chunk1 = new Buffer([0x00, 0x52, 0x45, 0x53, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00]); // NOOP var chunk2 = new Buffer([0x00, 0x52, 0x45, 0x53, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00]); // NO_JOB var chunk = Buffer.concat([chunk1, chunk2]); - var counter = 0; js.clientOrWorker._response = sinon.spy(); js.connected = true; js._processData(chunk); @@ -260,24 +259,23 @@ describe('JobServer', function() { done(); }) }) - // it('should process more packet with one messages correctly', function() { - // var chunk1 = new Buffer([0x00, 0x52, 0x45, 0x53, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00]); // JOB_ASSIGN - // var chunk2 = new Buffer([0x00, 0x52, 0x45, 0x53, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00]); // - // var chunk = Buffer.concat([chunk1, chunk2]); - // var counter = 0; - // js.clientOrWorker._response = sinon.spy(); - // js.connected = true; - // js._processData(chunk); - // // '_processData' works recursively in this case; the second call is via 'process.nextTick' - // // so the asserts must be in the next tick - // process.nextTick(function() { - // should.not.exist(js.segmentedPacket); - // should.not.exist(js.headerfrag); - // js.clientOrWorker._response.calledTwice.should.be.true; - // js.clientOrWorker._response.getCall(0).args[1].should.equal(protocol.PACKET_TYPES.NOOP); - // }) - // }) - it('PR 41: should concatenate message with header splitted into two', function() { + it('should process more packet with one messages correctly', function() { + var chunk1 = new Buffer([0x00, 0x52, 0x45, 0x53, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x14]); // JOB_ASSIGN + var chunk2 = new Buffer([0x48, 0x3a, 0x6c, 0x61, 0x70, 0x3a, 0x31, 0x00, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x00, + 0x74, 0x65, 0x73, 0x74]); + js.clientOrWorker._response = sinon.spy(); + js.connected = true; + js._processData(chunk1); + should.exist(js.segmentedPacket); + should.not.exist(js.headerfrag); + js.clientOrWorker._response.called.should.be.false; + js._processData(chunk2); + should.not.exist(js.segmentedPacket); + should.not.exist(js.headerfrag); + js.clientOrWorker._response.calledOnce.should.be.true; + js.clientOrWorker._response.getCall(0).args[1].should.equal(protocol.PACKET_TYPES.JOB_ASSIGN); + }) + it('PR 41: should concatenate one message with header splitted into two packets', function() { var chunk1 = new Buffer([0x00, 0x52, 0x45]); var chunk2 = new Buffer([0x53, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, // NOOP 0x00, 0x00, 0x00]); // + 3 bytes to be >= 12