[Groonga-commit] droonga/fluent-plugin-droonga at d6e4670 [master] Test output format of Groonga commands correctly

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Jan 24 13:35:35 JST 2014


YUKI Hiroshi	2014-01-24 13:35:35 +0900 (Fri, 24 Jan 2014)

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

  Message:
    Test output format of Groonga commands correctly

  Modified files:
    test/unit/plugin/handler/groonga/test_column_create.rb
    test/unit/plugin/handler/groonga/test_table_create.rb
    test/unit/plugin/handler/groonga/test_table_remove.rb
    test/unit/plugin/handler/test_groonga.rb

  Modified: test/unit/plugin/handler/groonga/test_column_create.rb (+6 -2)
===================================================================
--- test/unit/plugin/handler/groonga/test_column_create.rb    2014-01-24 13:26:54 +0900 (e64f33a)
+++ test/unit/plugin/handler/groonga/test_column_create.rb    2014-01-24 13:35:35 +0900 (e55a5ca)
@@ -19,7 +19,9 @@ class ColumnCreateTest < GroongaHandlerTest
     process(:column_create,
             {"table" => "Books", "name" => "title", "type" => "ShortText"})
     response =****@messe*****
-    assert_result_equal(
+    assert_valid_output(response)
+    response = response["result"]
+    assert_equal(
       [NORMALIZED_HEADER_SUCCESS, true],
       [normalize_header(response.first), response.last]
     )
@@ -29,7 +31,9 @@ class ColumnCreateTest < GroongaHandlerTest
     process(:column_create,
             {"table" => "Unknown", "name" => "title", "type" => "ShortText"})
     response =****@messe*****
-    assert_result_equal(
+    assert_valid_output(response)
+    response = response["result"]
+    assert_equal(
       [NORMALIZED_HEADER_INVALID_ARGUMENT, false],
       [normalize_header(response.first), response.last]
     )

  Modified: test/unit/plugin/handler/groonga/test_table_create.rb (+6 -2)
===================================================================
--- test/unit/plugin/handler/groonga/test_table_create.rb    2014-01-24 13:26:54 +0900 (d32b1e8)
+++ test/unit/plugin/handler/groonga/test_table_create.rb    2014-01-24 13:35:35 +0900 (2f0820b)
@@ -17,7 +17,9 @@ class TableCreateTest < GroongaHandlerTest
   def test_success
     process(:table_create, {"name" => "Books"})
     response =****@messe*****
-    assert_result_equal(
+    assert_valid_output(response)
+    response = response["result"]
+    assert_equal(
       [NORMALIZED_HEADER_SUCCESS, true],
       [normalize_header(response.first), response.last]
     )
@@ -26,7 +28,9 @@ class TableCreateTest < GroongaHandlerTest
   def test_failure
     process(:table_create, {})
     response =****@messe*****
-    assert_result_equal(
+    assert_valid_output(response)
+    response = response["result"]
+    assert_equal(
       [NORMALIZED_HEADER_INVALID_ARGUMENT, false],
       [normalize_header(response.first), response.last]
     )

  Modified: test/unit/plugin/handler/groonga/test_table_remove.rb (+6 -2)
===================================================================
--- test/unit/plugin/handler/groonga/test_table_remove.rb    2014-01-24 13:26:54 +0900 (9c2659d)
+++ test/unit/plugin/handler/groonga/test_table_remove.rb    2014-01-24 13:35:35 +0900 (3c3272e)
@@ -22,7 +22,9 @@ class TableRemoveTest < GroongaHandlerTest
   def test_success
     process(:table_remove, {"name" => "Books"})
     response =****@messe*****
-    assert_result_equal(
+    assert_valid_output(response)
+    response = response["result"]
+    assert_equal(
       [NORMALIZED_HEADER_SUCCESS, true],
       [normalize_header(response.first), response.last]
     )
@@ -33,7 +35,9 @@ class TableRemoveTest < GroongaHandlerTest
   def test_failure
     process(:table_remove, {})
     response =****@messe*****
-    assert_result_equal(
+    assert_valid_output(response)
+    response = response["result"]
+    assert_equal(
       [NORMALIZED_HEADER_INVALID_ARGUMENT, false],
       [normalize_header(response.first), response.last]
     )

  Modified: test/unit/plugin/handler/test_groonga.rb (+10 -7)
===================================================================
--- test/unit/plugin/handler/test_groonga.rb    2014-01-24 13:26:54 +0900 (f330dc9)
+++ test/unit/plugin/handler/test_groonga.rb    2014-01-24 13:35:35 +0900 (1abae91)
@@ -67,13 +67,16 @@ class GroongaHandlerTest < Test::Unit::TestCase
     NORMALIZED_ELAPSED_TIME,
   ]
 
-  def format_outputs(result)
-    {
-      "result" => result,
+  def assert_valid_output(output)
+    expected = {
+      "result" => [],
     }
-  end
-
-  def assert_result_equal(expected, actual)
-    assert_equal(format_outputs(expected), format_outputs(actual))
+    normalized_output = Marshal.load(Marshal.dump(output))
+    normalized_output.each do |key, value|
+      if value.is_a?(Array)
+        normalized_output[key] = []
+      end
+    end
+    assert_equal(expected, normalized_output)
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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