Kouhei Sutou
null+****@clear*****
Fri Aug 31 10:51:59 JST 2018
Kouhei Sutou 2018-08-31 10:51:59 +0900 (Fri, 31 Aug 2018) Revision: cab17d1b4e412e0fc0c70bd729a798db07497ae6 https://github.com/groonga/groonga-query-log/commit/cab17d1b4e412e0fc0c70bd729a798db07497ae6 Message: run-regression-test: support labeled drilldown Modified files: lib/groonga-query-log/response-comparer.rb test/test-response-comparer.rb Modified: lib/groonga-query-log/response-comparer.rb (+21 -6) =================================================================== --- lib/groonga-query-log/response-comparer.rb 2018-08-30 12:34:30 +0900 (fe44f66) +++ lib/groonga-query-log/response-comparer.rb 2018-08-31 10:51:59 +0900 (1ba4bb0) @@ -255,15 +255,30 @@ module GroongaQueryLog drilldowns1 =****@respo*****[1..-1] || [] drilldowns2 =****@respo*****[1..-1] || [] return false if drilldowns1.size != drilldowns2.size + drilldown_classes1 = drilldowns1.collect(&:class) + drilldown_classes2 = drilldowns2.collect(&:class) + return false if drilldown_classes1 != drilldown_classes2 - 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) + + if drilldown_classes1 == [Hash] + drilldowns1 = drilldowns1[0] + drilldowns2 = drilldowns2[0] + drilldowns1.each do |drilldown_label, drilldown1| + next if ignored_drilldown_keys.include?(drilldown_label) + drilldown2 = drilldowns2[drilldown_label] + return false unless same_record_set?(drilldown1, drilldown2) + end + else + drilldown_keys =****@comma***** + 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 end + true end Modified: test/test-response-comparer.rb (+80 -0) =================================================================== --- test/test-response-comparer.rb 2018-08-30 12:34:30 +0900 (aa14b7b) +++ test/test-response-comparer.rb 2018-08-31 10:51:59 +0900 (3d536fe) @@ -438,6 +438,86 @@ class ResponseComparerTest < Test::Unit::TestCase end end + class LabeledDrilldownTest < self + def create_response(drilldown) + @command["drilldown[name].keys"] = "name" + [ + [ + [10], + [["_id", "UInt32"]], + ], + { + "name" => [ + [drilldown.size * 2], + [["_key", "ShortText"], ["_nsubrecs", "Int32"]], + *drilldown, + ], + } + ] + end + + def test_same + response1 = create_response([["A", 10], ["B", 2]]) + response2 = create_response([["A", 10], ["B", 2]]) + assert do + same?(response1, response2) + end + end + + def test_not_same + response1 = create_response([["A", 11], ["B", 2]]) + response2 = create_response([["A", 10], ["B", 2]]) + assert do + not same?(response1, response2) + end + end + + class IgnoreDrilldownKeysTest < self + def create_response(drilldown1, drilldown2) + @command["drilldown[columns1].keys"] = "column1" + @command["drilldown[columns2].keys"] = "column2" + [ + [ + [10], + [["_id", "UInt32"]], + ], + { + "column1" => [ + [drilldown1.size * 2], + [["_key", "ShortText"], ["_nsubrecs", "Int32"]], + *drilldown1, + ], + "column2" => [ + [drilldown2.size * 2], + [["_key", "ShortText"], ["_nsubrecs", "Int32"]], + *drilldown2, + ], + }, + ] + end + + def test_same + 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 + 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 def test_with_location response1_header = [ -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180831/d8d2af24/attachment-0001.htm