SHIMODA Hiroshi
null+****@clear*****
Wed Aug 15 16:01:27 JST 2012
SHIMODA Hiroshi 2012-08-15 16:01:27 +0900 (Wed, 15 Aug 2012) New Revision: aa1005ee99511f74e28dae116cf3f7dcfba9991b https://github.com/groonga/gcs/commit/aa1005ee99511f74e28dae116cf3f7dcfba9991b Log: Fix tests around hostname Modified files: test/api-search.test.js test/dashboard.test.js test/test-utils.js Modified: test/api-search.test.js (+1 -1) =================================================================== --- test/api-search.test.js 2012-08-15 15:54:08 +0900 (34cee29) +++ test/api-search.test.js 2012-08-15 16:01:27 +0900 (4bebef4) @@ -23,7 +23,7 @@ suite('Search API', function() { function testSearch(path, message, host, callback) { test('GET ' + path + ' ' + message, function(done) { var options = { - host: utils.testBaseHost, + host: 'localhost', port: utils.testPort, path: path, headers: {Host: host} Modified: test/dashboard.test.js (+16 -29) =================================================================== --- test/dashboard.test.js 2012-08-15 15:54:08 +0900 (89e3370) +++ test/dashboard.test.js 2012-08-15 16:01:27 +0900 (ddce25e) @@ -1,6 +1,5 @@ var utils = require('./test-utils'); var assert = require('chai').assert; -var http = require('http'); var fs = require('fs'); suite('dashboard', function() { @@ -15,40 +14,28 @@ suite('dashboard', function() { }); test('GET /', function(done) { - var options = { - host: utils.testBaseHost, - port: utils.testPort, - path: '/' - }; - http.get(options, function(response) { - assert.equal(response.statusCode, 200); - var body = ''; - response.on('data', function(data) { - body += data; - }); - response.on('end', function() { - assert.match(body, /Groonga CloudSearch/); + utils + .get('/') + .next(function(response) { + assert.equal(response.statusCode, 200); + assert.match(response.body, /Groonga CloudSearch/); done(); + }) + .error(function(error) { + done(error); }); - }); }); test('GET /javascripts/templates.js', function(done) { - var options = { - host: utils.testBaseHost, - port: utils.testPort, - path: '/javascripts/templates.js' - }; - http.get(options, function(response) { - assert.equal(response.statusCode, 200); - var body = ''; - response.on('data', function(data) { - body += data; - }); - response.on('end', function() { - assert.include(body, "this.JST"); + utils + .get('/javascripts/templates.js') + .next(function(response) { + assert.equal(response.statusCode, 200); + assert.include(response.body, "this.JST"); done(); + }) + .error(function(error) { + done(error); }); - }); }); }); Modified: test/test-utils.js (+9 -7) =================================================================== --- test/test-utils.js 2012-08-15 15:54:08 +0900 (35be163) +++ test/test-utils.js 2012-08-15 16:01:27 +0900 (57220f3) @@ -11,18 +11,20 @@ var spawn = require('child_process').spawn; var temporaryDirectory = exports.temporaryDirectory = path.join(__dirname, 'tmp'); -var testBaseHost = 'api.localhost:80'; -var testConfigurationHost = 'configuration.localhost:80'; +var testBaseHost = 'api.localhost'; +var testConfigurationHost = 'configuration.localhost'; var testPort = 3333; exports.testBaseHost = testBaseHost; exports.testConfigurationHost = testConfigurationHost; exports.testPort = testPort; function setupServer(context) { - var server = gcsServer.createServer({ context: context, - port: testPort, - baseHost: exports.testBaseHost, - configurationHost: exports.testConfigurationHost }); + var server = gcsServer.createServer({ + context: context, + port: testPort, + baseHost: exports.testBaseHost + ':80', + configurationHost: exports.testConfigurationHost + ':80' + }); server.listen(testPort); return server; } @@ -32,7 +34,7 @@ function sendRequest(method, path, postData, headers) { var deferred = new Deferred(); var options = { - host: testBaseHost, + host: 'localhost', port: testPort, path: path, method: method, -------------- next part -------------- HTML����������������������������...Download