YUKI Hiroshi
null+****@clear*****
Fri Jan 11 18:24:18 JST 2013
YUKI Hiroshi 2013-01-11 18:24:18 +0900 (Fri, 11 Jan 2013) New Revision: 6d63855cc1f724584041501e37223d770508693b https://github.com/groonga/express-kotoumi/commit/6d63855cc1f724584041501e37223d770508693b Log: Include message type to the envelope Modified files: lib/backend-adaptor.js test/backend-adaptor.test.js Modified: lib/backend-adaptor.js (+2 -1) =================================================================== --- lib/backend-adaptor.js 2013-01-10 19:22:55 +0900 (d3c65bd) +++ lib/backend-adaptor.js 2013-01-11 18:24:18 +0900 (c376b3d) @@ -86,12 +86,13 @@ function getCurrentTime() { return new Date().toISOString(); } -Connection.prototype.emitMessage = function(body, callback) { +Connection.prototype.emitMessage = function(type, body, callback) { var id = createId(); var envelope = { id: id, date: getCurrentTime(), statusCode: 200, + type: type, body: body }; if (callback) { Modified: test/backend-adaptor.test.js (+6 -2) =================================================================== --- test/backend-adaptor.test.js 2013-01-10 19:22:55 +0900 (90b193b) +++ test/backend-adaptor.test.js 2013-01-11 18:24:18 +0900 (0305e3f) @@ -29,11 +29,12 @@ suite('Connection', function() { }); test('sending message without response (volatile message)', function() { - var message = connection.emitMessage({ command: 'foobar' }); + var message = connection.emitMessage('testRequest', { command: 'foobar' }); assert.envelopeEqual(message, { id: TypeOf('string'), date: InstanceOf(Date), statusCode: 200, + type: 'testRequest', body: { command: 'foobar' } }); sender.assertSent('message', message); }); @@ -47,6 +48,7 @@ suite('Connection', function() { id: now.getTime(), date: now.toISOString(), statusCode: 200, + type: 'testResponse', body: 'first call' }; callback.takes(message); @@ -66,11 +68,12 @@ suite('Connection', function() { test('sending message with one response', function() { var callback = utils.createMockedMessageCallback(); - var message = connection.emitMessage({ command: 'foobar' }, callback); + var message = connection.emitMessage('testRequest', { command: 'foobar' }, callback); assert.envelopeEqual(message, { id: TypeOf('string'), date: InstanceOf(Date), statusCode: 200, + type: 'testRequest', body: { command: 'foobar' } }); sender.assertSent('message', message); @@ -80,6 +83,7 @@ suite('Connection', function() { date: now.toISOString(), replyTo: message.id, statusCode: 200, + type: 'testResponse', body: 'first call' }; callback.takes(response); -------------- next part -------------- HTML����������������������������... 下载