[Groonga-commit] groonga/express-kotoumi [master] Add test for message builder about search request, with options

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Jan 11 19:09:54 JST 2013


YUKI Hiroshi	2013-01-11 19:09:54 +0900 (Fri, 11 Jan 2013)

  New Revision: 164b552a118ba84936caab14aa684d5461b869f1
  https://github.com/groonga/express-kotoumi/commit/164b552a118ba84936caab14aa684d5461b869f1

  Log:
    Add test for message builder about search request, with options

  Modified files:
    test/builders-rest-request.test.js

  Modified: test/builders-rest-request.test.js (+52 -20)
===================================================================
--- test/builders-rest-request.test.js    2013-01-11 19:02:56 +0900 (73780b9)
+++ test/builders-rest-request.test.js    2013-01-11 19:09:54 +0900 (2b5b047)
@@ -2,29 +2,61 @@ var assert = require('chai').assert;
 
 var builders = require('../lib/builders/rest-request');
 
-suite('from search REST API', function() {
-  test('simple query', function() {
-    var params = {
-      tableName: 'test_table',
-      query:     'foobar'
+suite('building message from REST API request', function() {
+  suite('search', function() {
+    var outputAll = {
+      startTime:   true,
+      elapsedTime: true,
+      count:       true,
+      attributes:  true,
+      recodes:     true
     };
-    var expectedBody = {
-      queries: {
-        result: {
-          source: 'test_table',
-          query:  'foobar',
-          output: {
-            startTime:   true,
-            elapsedTime: true,
-            count:       true,
-            attributes:  true,
-            recodes:     true
+
+    test('simple query', function() {
+      var params = {
+        tableName: 'test_table',
+        query:     'foobar'
+      };
+      var expectedBody = {
+        queries: {
+          result: {
+            source: 'test_table',
+            query:  'foobar',
+            output: outputAll
           }
         }
-      }
-    };
-    var actualBody = builders.search({ params: params });
-    assert.deepEqual(actualBody, expectedBody);
+      };
+      var actualBody = builders.search({ params: params });
+      assert.deepEqual(actualBody, expectedBody);
+    });
+
+    test('with options', function() {
+      var params = {
+        tableName:  'people',
+        query:      'foobar',
+        offset:     '10',
+        limit:      '100',
+        match_to:   'realname,nickname',
+        order_by:   '-realname,-nickname',
+        attributes: 'realname,nickname,age,job'
+      };
+      var expectedBody = {
+        queries: {
+          result: {
+            source:  'people',
+            query:   'foobar',
+            offset:  '10',
+            limit:   '100',
+            matchTo: ['realname', 'nickname'],
+            orderBy: ['-realname', '-nickname'],
+            attributes: ['realname', 'nickname', 'age', 'job'],
+            output:  outputAll
+          }
+        }
+      };
+      var actualBody = builders.search({ params: params });
+      assert.deepEqual(actualBody, expectedBody);
+    });
   });
 });
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index