[Groonga-commit] groonga/groonga-query-log at c70d33b [master] verify-server: support all output_columns and rand() sort

Back to archive index

Kouhei Sutou null+****@clear*****
Fri May 16 17:21:50 JST 2014


Kouhei Sutou	2014-05-16 17:21:50 +0900 (Fri, 16 May 2014)

  New Revision: c70d33b5d76356dc566bb5a170d4207c8a98ee9c
  https://github.com/groonga/groonga-query-log/commit/c70d33b5d76356dc566bb5a170d4207c8a98ee9c

  Message:
    verify-server: support all output_columns and rand() sort

  Modified files:
    lib/groonga/query-log/response-comparer.rb
    test/test-response-comparer.rb

  Modified: lib/groonga/query-log/response-comparer.rb (+13 -2)
===================================================================
--- lib/groonga/query-log/response-comparer.rb    2014-05-16 17:18:12 +0900 (aa19c13)
+++ lib/groonga/query-log/response-comparer.rb    2014-05-16 17:21:50 +0900 (ebc8bfc)
@@ -85,8 +85,19 @@ module Groonga
       def same_random_sort_response?
         records_result1 =****@respo*****[0] || []
         records_result2 =****@respo*****[0] || []
-        records_result1.size == records_result2.size and
-          records_result1[0..1] == records_result2[0..1]
+        return false if records_result1.size != records_result2.size
+
+        n_hits1 = records_result1[0]
+        n_hits2 = records_result2[0]
+        return false if n_hits1 != n_hits2
+
+        columns1 = records_result1[1]
+        columns2 = records_result2[1]
+        if all_output_columns?
+          columns1.sort_by(&:first) == columns2.sort_by(&:first)
+        else
+          columns1 == columns2
+        end
       end
 
       def all_output_columns?

  Modified: test/test-response-comparer.rb (+24 -0)
===================================================================
--- test/test-response-comparer.rb    2014-05-16 17:18:12 +0900 (e11d465)
+++ test/test-response-comparer.rb    2014-05-16 17:21:50 +0900 (6c8e477)
@@ -58,19 +58,43 @@ class ResponseComparerTest < Test::Unit::TestCase
         end
 
         def test_different_order
+          @command["output_columns"] = "_id"
           assert_true(same?([[[3], [["_id", "UInt32"]], [1], [2], [3]]],
                             [[[3], [["_id", "UInt32"]], [3], [2], [1]]]))
         end
 
         def test_different_attributes
+          @command["output_columns"] = "_id, age"
           assert_false(same?([[[3], [["_id", "UInt32"]], [1], [2], [3]]],
                              [[[3], [["age", "UInt32"]], [1], [2], [3]]]))
         end
 
         def test_different_n_records
+          @command["output_columns"] = "_id"
           assert_false(same?([[[3], [["_id", "UInt32"]], [1], [2]]],
                              [[[3], [["_id", "UInt32"]], [1], [2], [3]]]))
         end
+
+        def test_all_output_columns
+          assert_true(same?([
+                              [
+                                [3],
+                                [["_id", "UInt32"], ["_key", "ShortText"]],
+                                [1, "1"],
+                                [2, "2"],
+                                [3, "3"],
+                              ],
+                            ],
+                            [
+                              [
+                                [3],
+                                [["_key", "ShortText"], ["_id", "UInt32"]],
+                                ["3", 3],
+                                ["2", 2],
+                                ["1", 1],
+                              ],
+                            ]))
+        end
       end
 
       class DetectRandTest < self
-------------- next part --------------
HTML����������������������������...
下載 



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