[Groonga-commit] groonga/groonga-query-log at d6ec928 [master] format-regression-test-logs: show command inspection

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Nov 20 14:26:21 JST 2014


Kouhei Sutou	2014-11-20 14:26:21 +0900 (Thu, 20 Nov 2014)

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

  Message:
    format-regression-test-logs: show command inspection

  Added files:
    test/fixtures/regression-test-logs/url-format.log
  Modified files:
    lib/groonga/query-log/command/format-regression-test-logs.rb
    test/command/test-format-regression-test-logs.rb

  Modified: lib/groonga/query-log/command/format-regression-test-logs.rb (+16 -1)
===================================================================
--- lib/groonga/query-log/command/format-regression-test-logs.rb    2014-11-20 14:12:27 +0900 (25c494d)
+++ lib/groonga/query-log/command/format-regression-test-logs.rb    2014-11-20 14:26:21 +0900 (f52f715)
@@ -21,6 +21,8 @@ require "pp"
 require "optparse"
 require "json"
 
+require "groonga/command/parser"
+
 require "groonga/query-log/version"
 
 module Groonga
@@ -115,7 +117,7 @@ module Groonga
             Tempfile.open("response2") do |response2_file|
               PP.pp(JSON.parse(response2), response2_file)
               response2_file.flush
-              puts(command)
+              report_command(command)
               system("diff",
                      "--label=old",
                      "--label=new",
@@ -124,6 +126,19 @@ module Groonga
             end
           end
         end
+
+        def report_command(command)
+          puts(command)
+          parsed_command = Groonga::Command::Parser.parse(command)
+          puts("Name: #{parsed_command.name}")
+          puts("Arguments:")
+          sorted_arguments = parsed_command.arguments.sort_by do |key, value|
+            key
+          end
+          sorted_arguments.each do |key, value|
+            puts("  #{key}: #{value}")
+          end
+        end
       end
     end
   end

  Modified: test/command/test-format-regression-test-logs.rb (+27 -1)
===================================================================
--- test/command/test-format-regression-test-logs.rb    2014-11-20 14:12:27 +0900 (f4a6f48)
+++ test/command/test-format-regression-test-logs.rb    2014-11-20 14:26:21 +0900 (ca4d6fe)
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+#
 # Copyright (C) 2014  Kouhei Sutou <kou �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
@@ -47,6 +49,9 @@ class FormatRegressionTestLogsCommandTest < Test::Unit::TestCase
   def test_command_format
     output = <<-OUTPUT
 select Logs
+Name: select
+Arguments:
+  table: Logs
 --- old
 +++ new
 @@ -1,4 +1,4 @@
@@ -55,8 +60,29 @@ select Logs
    [1, \"log message1\"],
 -  [2, \"log message2\"]]]
 +  [3, \"log message3\"]]]
-OUTPUT
+    OUTPUT
     assert_equal([true, output],
                  run_command([fixture_path("command-format.log")]))
   end
+
+  def test_url_format
+    output = <<-OUTPUT
+/d/select?table=Logs&match_columns=message&query=%E7%84%BC%E8%82%89
+Name: select
+Arguments:
+  match_columns: message
+  query: 焼肉
+  table: Logs
+--- old
++++ new
+@@ -1,4 +1,4 @@
+ [[[2],
+   [[\"_id\", \"UInt32\"], [\"message\", \"Text\"]],
+   [1, \"log message1: 焼肉\"],
+-  [2, \"log message2: 焼肉\"]]]
++  [3, \"log message3: 焼肉\"]]]
+    OUTPUT
+    assert_equal([true, output],
+                 run_command([fixture_path("url-format.log")]))
+  end
 end

  Added: test/fixtures/regression-test-logs/url-format.log (+3 -0) 100644
===================================================================
--- /dev/null
+++ test/fixtures/regression-test-logs/url-format.log    2014-11-20 14:26:21 +0900 (ce833db)
@@ -0,0 +1,3 @@
+command: /d/select?table=Logs&match_columns=message&query=%E7%84%BC%E8%82%89
+response1: [[[2], [["_id", "UInt32"], ["message", "Text"]], [1, "log message1: 焼肉"], [2, "log message2: 焼肉"]]]
+response2: [[[2], [["_id", "UInt32"], ["message", "Text"]], [1, "log message1: 焼肉"], [3, "log message3: 焼肉"]]]
-------------- next part --------------
HTML����������������������������...
Download 



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