[Groonga-commit] groonga/groonga-query-log at 2620dad [master] test: add a test for format-regression-test-logs command

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Nov 20 14:12:27 JST 2014


Kouhei Sutou	2014-11-20 14:12:27 +0900 (Thu, 20 Nov 2014)

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

  Message:
    test: add a test for format-regression-test-logs command

  Added files:
    test/command/test-format-regression-test-logs.rb
    test/fixtures/regression-test-logs/command-format.log
  Modified files:
    test/helper.rb

  Added: test/command/test-format-regression-test-logs.rb (+62 -0) 100644
===================================================================
--- /dev/null
+++ test/command/test-format-regression-test-logs.rb    2014-11-20 14:12:27 +0900 (f4a6f48)
@@ -0,0 +1,62 @@
+# Copyright (C) 2014  Kouhei Sutou <kou �� clear-code.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+require "groonga/query-log/command/format-regression-test-logs"
+
+class FormatRegressionTestLogsCommandTest < Test::Unit::TestCase
+  include Fixture
+
+  def setup
+    @command = Groonga::QueryLog::Command::FormatRegressionTestLogs.new
+  end
+
+  def run_command(command_line)
+    stdout = $stdout.dup
+    output = Tempfile.open("output")
+    $stdout.reopen(output)
+    succees =****@comma*****(command_line)
+    output.rewind
+    [succees, output.read]
+  ensure
+    $stdout.reopen(stdout)
+  end
+
+  def fixture_path(*components)
+    super("regression-test-logs", *components)
+  end
+
+  def test_nothing
+    input = Tempfile.new("format-regression-test-logs")
+    assert_equal([true, ""],
+                 run_command([input.path]))
+  end
+
+  def test_command_format
+    output = <<-OUTPUT
+select 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("command-format.log")]))
+  end
+end

  Added: test/fixtures/regression-test-logs/command-format.log (+3 -0) 100644
===================================================================
--- /dev/null
+++ test/fixtures/regression-test-logs/command-format.log    2014-11-20 14:12:27 +0900 (e88f7f7)
@@ -0,0 +1,3 @@
+command: select Logs
+response1: [[[2], [["_id", "UInt32"], ["message", "Text"]], [1, "log message1"], [2, "log message2"]]]
+response2: [[[2], [["_id", "UInt32"], ["message", "Text"]], [1, "log message1"], [3, "log message3"]]]

  Modified: test/helper.rb (+6 -0)
===================================================================
--- test/helper.rb    2014-11-20 14:07:05 +0900 (fdeb24c)
+++ test/helper.rb    2014-11-20 14:12:27 +0900 (ff2ebfa)
@@ -22,3 +22,9 @@ require "stringio"
 require "groonga/command"
 
 require "groonga/query-log"
+
+module Fixture
+  def fixture_path(*components)
+    File.join(File.dirname(__FILE__), "fixtures", *components)
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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