[Groonga-commit] groonga/fluent-plugin-droonga [master] Return empty response for empty request

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Apr 9 17:20:34 JST 2013


Kouhei Sutou	2013-04-09 17:20:34 +0900 (Tue, 09 Apr 2013)

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

  Message:
    Return empty response for empty request

  Added files:
    test/plugin/test_handler_search.rb
  Modified files:
    lib/droonga/plugin/handler_search.rb

  Modified: lib/droonga/plugin/handler_search.rb (+3 -1)
===================================================================
--- lib/droonga/plugin/handler_search.rb    2013-04-09 17:14:20 +0900 (6d98c9f)
+++ lib/droonga/plugin/handler_search.rb    2013-04-09 17:20:34 +0900 (7138487)
@@ -27,12 +27,14 @@ module Droonga
     command :search
     def search(request)
       queries = request["queries"]
-      results = {}
       outputs = {}
+      return outputs if queries.nil?
+
       query_sorter = QuerySorter.new
       queries.each do |name, query|
         query_sorter.add(name, [query["source"]])
       end
+      results = {}
       query_sorter.tsort.each do |name|
         if queries[name]
           search_query(name, queries, results, outputs)

  Added: test/plugin/test_handler_search.rb (+53 -0) 100644
===================================================================
--- /dev/null
+++ test/plugin/test_handler_search.rb    2013-04-09 17:20:34 +0900 (b84680e)
@@ -0,0 +1,53 @@
+# Copyright (C) 2013 droonga project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+require "droonga/plugin/handler_search"
+
+class SearchHandlerTest < Test::Unit::TestCase
+  def setup
+    setup_database
+    setup_handler
+  end
+
+  def teardown
+    teardown_handler
+    teardown_database
+  end
+
+  private
+  def setup_database
+    restore(fixture_data("document.grn"))
+    @database = Groonga::Database.open(@database_path.to_s)
+  end
+
+  def teardown_database
+    @database.close
+    @database = nil
+  end
+
+  def setup_handler
+    @handler = Droonga::SearchHandler.new(Groonga::Context.default)
+  end
+
+  def teardown_handler
+    @handler = nil
+  end
+
+  class NoParameterTest < self
+    def test_empty
+      assert_equal({}, @handler.search({}))
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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