YUKI Hiroshi
null+****@clear*****
Fri Aug 24 15:37:20 JST 2012
YUKI Hiroshi 2012-08-24 15:37:20 +0900 (Fri, 24 Aug 2012) New Revision: 29b2277f26c4ed614557f1dfce0f3b967c2a4347 https://github.com/groonga/gcs/commit/29b2277f26c4ed614557f1dfce0f3b967c2a4347 Log: Add test for compaibility of search API around return-fields option Modified files: test/api-search.test.js Modified: test/api-search.test.js (+39 -3) =================================================================== --- test/api-search.test.js 2012-08-23 15:05:30 +0900 (b57548a) +++ test/api-search.test.js 2012-08-24 15:37:20 +0900 (1f0e1a7) @@ -66,10 +66,14 @@ suite('Search API', function() { } suite('with fixture loaded', function() { + var domain; + setup(function() { utils.loadDumpFile(context, __dirname + '/fixture/companies/ddl.grn'); utils.loadDumpFile(context, __dirname + '/fixture/companies/configurations.grn'); utils.loadDumpFile(context, __dirname + '/fixture/companies/data.grn'); + + domain = new Domain('companies', context); }); testSearch('/2011-02-01/search?q=Hongo', @@ -123,9 +127,12 @@ suite('Search API', function() { ); testSearch('/2011-02-01/search?q=Hongo&' + - 'return-fields=address,description,name,age,product', - 'should return field values', + 'return-fields=address,description,name,age,product,unknown', + 'should return field values siecified by return-fields', 'search-companies-00000000000000000000000000.localhost', + function() { + domain.getIndexField('address').setReturnEnabled(false).saveOptionsSync(); + }, function(response) { var expected = { // FIXME rank: '-text_relevance', @@ -136,7 +143,7 @@ suite('Search API', function() { hit: [{ id: 'id3', data: { - address: ['Hongo, Tokyo, Japan'], + address: [], // "unreturnable" field should be empty! description: [''], name: ['ClearCode Inc.'], age: [3], @@ -154,6 +161,35 @@ suite('Search API', function() { } ); + testSearch('/2011-02-01/search?q=Hongo&' + + 'return-fields=unknown1,unknown2', + 'should return blank "data" by return-fields with unexisting fields', + 'search-companies-00000000000000000000000000.localhost', + function() { + domain.getIndexField('address').setReturnEnabled(false).saveOptionsSync(); + }, + function(response) { + var expected = { // FIXME + rank: '-text_relevance', + 'match-expr': "(label 'Hongo')", + hits: { + found: 1, + start: 0, + hit: [{ + id: 'id3', + data: {} + }] + }, + info: { + rid: '000000000000000000000000000000000000000000000000000000000000000', + 'time-ms': 0, // always 0 + 'cpu-time-ms': 0 + } + }; + assert.deepEqual(response.normalizedBody, expected); + } + ); + testSearch('/2011-02-01/search?q=Tokyo&facet=product', 'with facet "domain"', 'search-companies-00000000000000000000000000.localhost', -------------- next part -------------- HTML����������������������������...Download