[Groonga-commit] groonga/groonga-query-log at 775210a [master] test replayer: add a test for host option

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jul 5 18:31:59 JST 2013


Kouhei Sutou	2013-07-05 18:31:59 +0900 (Fri, 05 Jul 2013)

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

  Message:
    test replayer: add a test for host option

  Added files:
    test/test-replayer.rb
  Modified files:
    lib/groonga/query-log/replayer.rb

  Modified: lib/groonga/query-log/replayer.rb (+2 -2)
===================================================================
--- lib/groonga/query-log/replayer.rb    2013-07-05 18:30:49 +0900 (06a07c6)
+++ lib/groonga/query-log/replayer.rb    2013-07-05 18:31:59 +0900 (a5727b6)
@@ -26,10 +26,10 @@ require "groonga/query-log/parser"
 module Groonga
   module QueryLog
     class Replayer
-      def initialize
+      def initialize(options)
         @queue = Queue.new
         @responses = Queue.new
-        @options = Options.new
+        @options = options
       end
 
       def parse_command_line_options(arguments)

  Added: test/test-replayer.rb (+47 -0) 100644
===================================================================
--- /dev/null
+++ test/test-replayer.rb    2013-07-05 18:31:59 +0900 (20cec0a)
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2013  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
+
+class ReplayerTest < Test::Unit::TestCase
+  class OptionTest < self
+    def setup
+      @options = Groonga::QueryLog::Replayer::Options.new
+      @options.n_clients = 1
+    end
+
+    def test_host
+      host = "example.com"
+      @options.host = host
+      expected_open_options = {
+        :host     => host,
+        :port     => 10041,
+        :protocol => :gqtp,
+      }
+      client = Object.new
+      mock(Groonga::Client).open(expected_open_options).yields(client) do
+        client
+      end
+      replay
+    end
+
+    private
+    def replay
+      replayer = Groonga::QueryLog::Replayer.new(@options)
+      replayer.replay(StringIO.new(""))
+    end
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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