[Groonga-commit] groonga/groonga-query-log at 96f130f [master] response-comparer: add :ignored_drilldown_keys option

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 13 10:30:30 JST 2018


Kouhei Sutou	2018-06-13 10:30:30 +0900 (Wed, 13 Jun 2018)

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

  Message:
    response-comparer: add :ignored_drilldown_keys option

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

  Modified: lib/groonga-query-log/response-comparer.rb (+6 -1)
===================================================================
--- lib/groonga-query-log/response-comparer.rb    2018-06-13 10:17:23 +0900 (b9fee95)
+++ lib/groonga-query-log/response-comparer.rb    2018-06-13 10:30:30 +0900 (7713ac0)
@@ -20,8 +20,9 @@ module GroongaQueryLog
       @command = command
       @response1 = response1
       @response2 = response2
-      @options = options
+      @options = options.dup
       @options[:care_order] = true if @options[:care_order].nil?
+      @options[:ignored_drilldown_keys] ||= []
     end
 
     def same?
@@ -255,7 +256,11 @@ module GroongaQueryLog
       drilldowns2 =****@respo*****[1..-1] || []
       return false if drilldowns1.size != drilldowns2.size
 
+      drilldown_keys =****@comma*****
+      ignored_drilldown_keys = @options[:ignored_drilldown_keys]
       drilldowns1.each_with_index do |drilldown1, drilldown_index|
+        drilldown_key = drilldown_keys[drilldown_index]
+        next if ignored_drilldown_keys.include?(drilldown_key)
         drilldown2 = drilldowns2[drilldown_index]
         return false unless same_record_set?(drilldown1, drilldown2)
       end

  Modified: test/test-response-comparer.rb (+43 -0)
===================================================================
--- test/test-response-comparer.rb    2018-06-13 10:17:23 +0900 (6516dd9)
+++ test/test-response-comparer.rb    2018-06-13 10:30:30 +0900 (9c2fb61)
@@ -393,6 +393,49 @@ class ResponseComparerTest < Test::Unit::TestCase
           not same?(response1, response2)
         end
       end
+
+      class IgnoreDrilldownKeysTest < self
+        def create_response(drilldown1, drilldown2)
+          [
+            [
+              [10],
+              [["_id", "UInt32"]],
+            ],
+            [
+              [drilldown1.size * 2],
+              [["_key", "ShortText"], ["_nsubrecs", "Int32"]],
+              *drilldown1,
+            ],
+            [
+              [drilldown2.size * 2],
+              [["_key", "ShortText"], ["_nsubrecs", "Int32"]],
+              *drilldown2,
+            ],
+          ]
+        end
+
+        def test_same
+          @command["drilldown"] = "column1, column2"
+          response1 = create_response([["A", 10], ["B", 2]],
+                                      [["a", 11], ["b", 10]])
+          response2 = create_response([["A", 10], ["B", 2]],
+                                      [["a", 99], ["b", 20]])
+          assert do
+            same?(response1, response2, ignored_drilldown_keys: ["column2"])
+          end
+        end
+
+        def test_not_same
+          @command["drilldown"] = "column1, column2"
+          response1 = create_response([["A", 10], ["B", 2]],
+                                      [["a", 11], ["b", 10]])
+          response2 = create_response([["A", 10], ["B", 2]],
+                                      [["a", 99], ["b", 20]])
+          assert do
+            not same?(response1, response2)
+          end
+        end
+      end
     end
 
     class ErrorTest < self
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180613/b001376b/attachment-0001.htm 



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