null+****@clear*****
null+****@clear*****
2012年 7月 19日 (木) 15:20:25 JST
Yoji SHIDARA 2012-07-19 15:20:25 +0900 (Thu, 19 Jul 2012) New Revision: 2191f55ddf6562d14054ccd990b851e91fabe055 https://github.com/groonga/gcs/commit/2191f55ddf6562d14054ccd990b851e91fabe055 Log: Replace time-ms before test. #69 Modified files: test/api-search.test.js Modified: test/api-search.test.js (+16 -15) =================================================================== --- test/api-search.test.js 2012-07-19 13:42:49 +0900 (394f6bf) +++ test/api-search.test.js 2012-07-19 15:20:25 +0900 (faa38e3) @@ -40,6 +40,10 @@ suite('Search API', function() { }); } + function normalizeSearchResult(str) { + return str.replace(/"time-ms":\s*(?:[1-9]\d*|0)([,\}])/, '"time-ms":0$1'); + } + suite('with fixture loaded', function() { setup(function() { utils.loadDumpFile(context, __dirname + '/fixture/companies/ddl.grn'); @@ -50,9 +54,8 @@ suite('Search API', function() { 'should hit one entry', 'search-companies-00000000000000000000000000.localhost', function(response, body, done) { - var actual = JSON.parse(body); - assert.operator(actual.info['time-ms'], '>=', 0, 'time-ms is ok'); - actual.info['time-ms'] = 0; // always set 0 for test + var normalizedBody = normalizeSearchResult(body); + var actual = JSON.parse(normalizedBody); var expected = { // FIXME rank: '-text_relevance', 'match-expr': '', @@ -88,9 +91,8 @@ suite('Search API', function() { 'should hit three entries', 'search-companies-00000000000000000000000000.localhost', function(response, body, done) { - var actual = JSON.parse(body); - assert.operator(actual.info['time-ms'], '>=', 0, 'time-ms is ok'); - actual.info['time-ms'] = 0; // always set 0 for test + var normalizedBody = normalizeSearchResult(body); + var actual = JSON.parse(normalizedBody); var expected = { rank: '-text_relevance', 'match-expr': '', @@ -154,9 +156,8 @@ suite('Search API', function() { 'should return two hit entries', 'search-companies-00000000000000000000000000.localhost', function(response, body, done) { - var actual = JSON.parse(body); - assert.operator(actual.info['time-ms'], '>=', 0, 'time-ms is ok'); - actual.info['time-ms'] = 0; // always set 0 for test + var normalizedBody = normalizeSearchResult(body); + var actual = JSON.parse(normalizedBody); var expected = { rank: '-text_relevance', 'match-expr': '', @@ -207,8 +208,8 @@ suite('Search API', function() { 'should return offseted hit result', 'search-companies-00000000000000000000000000.localhost', function(response, body, done) { - var actual = JSON.parse(body); - actual.info['time-ms'] = 0; // always set 0 for test + var normalizedBody = normalizeSearchResult(body); + var actual = JSON.parse(normalizedBody); var expected = { rank: '-text_relevance', 'match-expr': '', @@ -259,8 +260,8 @@ suite('Search API', function() { 'should not match with any entry', 'search-companies-00000000000000000000000000.localhost', function(response, body, done) { - var actual = JSON.parse(body); - actual.info['time-ms'] = 0; // always set 0 for test + var normalizedBody = normalizeSearchResult(body); + var actual = JSON.parse(normalizedBody); var expected = { rank: '-text_relevance', 'match-expr': '', @@ -293,8 +294,8 @@ suite('Search API', function() { 'should match with using synonyms', 'search-companies-00000000000000000000000000.localhost', function(response, body, done) { - var actual = JSON.parse(body); - actual.info['time-ms'] = 0; // always set 0 for test + var normalizedBody = normalizeSearchResult(body); + var actual = JSON.parse(normalizedBody); var expected = { rank: '-text_relevance', 'match-expr': '', -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...Download