[Groonga-commit] droonga/fluent-plugin-droonga at 20258a9 [master] test: extract common code

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jan 30 15:41:46 JST 2014


Kouhei Sutou	2014-01-30 15:41:46 +0900 (Thu, 30 Jan 2014)

  New Revision: 20258a9e3cfc0f108d91241f80b6b563ba0d0075
  https://github.com/droonga/fluent-plugin-droonga/commit/20258a9e3cfc0f108d91241f80b6b563ba0d0075

  Message:
    test: extract common code

  Modified files:
    test/unit/plugin/distributor/test_search_planner.rb

  Modified: test/unit/plugin/distributor/test_search_planner.rb (+27 -55)
===================================================================
--- test/unit/plugin/distributor/test_search_planner.rb    2014-01-30 15:38:44 +0900 (a48bc5f)
+++ test/unit/plugin/distributor/test_search_planner.rb    2014-01-30 15:41:46 +0900 (cdfbd27)
@@ -54,6 +54,26 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
     end
   end
 
+  def expected_dependencies(reduce_inputs, gather_inputs)
+    [
+      {
+        "type"    => "search_reduce",
+        "inputs"  => reduce_inputs,
+        "outputs" => gather_inputs,
+      },
+      {
+        "type"    => "search_gather",
+        "inputs"  => gather_inputs,
+        "outputs" => nil,
+      },
+      {
+        "type"    => "broadcast",
+        "inputs"  => nil,
+        "outputs" => reduce_inputs,
+      },
+    ]
+  end
+
   class MultipleQueriesTest < self
     class MultipleOutputsTest < self
       def setup
@@ -86,35 +106,19 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
       end
 
       def test_dependencies
-        search_reduce_inputs = [
+        reduce_inputs = [
           "errors",
           "query1",
           "query2",
           "query3",
         ]
-        search_gather_inputs = [
+        gather_inputs = [
           "errors_reduced",
           "query1_reduced",
           "query2_reduced",
           "query3_reduced",
         ]
-        assert_equal([
-                       {
-                         "type"    => "search_reduce",
-                         "inputs"  => search_reduce_inputs,
-                         "outputs" => search_gather_inputs,
-                       },
-                       {
-                         "type"    => "search_gather",
-                         "inputs"  => search_gather_inputs,
-                         "outputs" => nil,
-                       },
-                       {
-                         "type"    => "broadcast",
-                         "inputs"  => nil,
-                         "outputs" => search_reduce_inputs,
-                       },
-                     ],
+        assert_equal(expected_dependencies(reduce_inputs, gather_inputs),
                      dependencies)
       end
     end
@@ -137,25 +141,9 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
       end
 
       def test_dependencies
-        search_reduce_inputs = ["errors"]
-        search_gather_inputs = ["errors_reduced"]
-        assert_equal([
-                       {
-                         "type"    => "search_reduce",
-                         "inputs"  => search_reduce_inputs,
-                         "outputs" => search_gather_inputs,
-                       },
-                       {
-                         "type"    => "search_gather",
-                         "inputs"  => search_gather_inputs,
-                         "outputs" => nil,
-                       },
-                       {
-                         "type"    => "broadcast",
-                         "inputs"  => nil,
-                         "outputs" => search_reduce_inputs,
-                       },
-                     ],
+        reduce_inputs = ["errors"]
+        gather_inputs = ["errors_reduced"]
+        assert_equal(expected_dependencies(reduce_inputs, gather_inputs),
                      dependencies)
       end
 
@@ -224,23 +212,7 @@ class DistributedSearchPlannerTest < Test::Unit::TestCase
           "errors_reduced",
           "users_reduced",
         ]
-        assert_equal([
-                       {
-                         "type"    => "search_reduce",
-                         "inputs"  => search_reduce_inputs,
-                         "outputs" => search_gather_inputs,
-                       },
-                       {
-                         "type"    => "search_gather",
-                         "inputs"  => search_gather_inputs,
-                         "outputs" => nil,
-                       },
-                       {
-                         "type"    => "broadcast",
-                         "inputs"  => nil,
-                         "outputs" => search_reduce_inputs,
-                       },
-                     ],
+        assert_equal(expected_dependencies(reduce_inputs, gather_inputs),
                      dependencies)
       end
 
-------------- next part --------------
HTML����������������������������...
Download 



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