[Groonga-commit] groonga/fluent-plugin-droonga at 4bdb8da [master] Add tests for array/string type "matchTo" option of hash style conditions

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Apr 19 17:47:20 JST 2013


YUKI Hiroshi	2013-04-19 17:47:20 +0900 (Fri, 19 Apr 2013)

  New Revision: 4bdb8da4e78a04b5c2ac7c481ae445a92bf95750
  https://github.com/groonga/fluent-plugin-droonga/commit/4bdb8da4e78a04b5c2ac7c481ae445a92bf95750

  Message:
    Add tests for array/string type "matchTo" option of hash style conditions

  Modified files:
    test/plugin/test_handler_search.rb

  Modified: test/plugin/test_handler_search.rb (+49 -0)
===================================================================
--- test/plugin/test_handler_search.rb    2013-04-19 17:24:50 +0900 (9765763)
+++ test/plugin/test_handler_search.rb    2013-04-19 17:47:20 +0900 (1d2cd29)
@@ -95,6 +95,55 @@ class SearchHandlerTest < Test::Unit::TestCase
     end
   end
 
+  class HashQueryTest < self
+    def test_string_matchTo
+      request = base_request
+      request["queries"]["sections-result"]["condition"] = {
+        "query" => "Groonga",
+        "matchTo" => "title"
+      }
+      assert_search({
+                      "sections-result" => {
+                        "records" => [
+                          { "title" => "Groonga overview" },
+                        ],
+                      },
+                    },
+                    request)
+    end
+
+    def test_array_matchTo
+      request = base_request
+      request["queries"]["sections-result"]["condition"] = {
+        "query" => "Groonga",
+        "matchTo" => ["title"]
+      }
+      assert_search({
+                      "sections-result" => {
+                        "records" => [
+                          { "title" => "Groonga overview" },
+                        ],
+                      },
+                    },
+                    request)
+    end
+
+    def base_request
+      {
+        "queries" => {
+          "sections-result" => {
+            "source" => "Sections",
+            "output" => {
+              "format" => "complex",
+              "limit" => 1,
+              "attributes" => ["title"],
+            },
+          },
+        },
+      }
+    end
+  end
+
   class SourceTest < self
     def test_non_existent
       assert_raise(Droonga::SearchHandler::UndefinedSourceError) do
-------------- next part --------------
HTML����������������������������...
Download 



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