[Groonga-commit] droonga/fluent-plugin-droonga at cdc52dc [master] Add test for GrongaCommandConverter with a sample test

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Sep 12 12:44:37 JST 2013


YUKI Hiroshi	2013-09-12 12:44:37 +0900 (Thu, 12 Sep 2013)

  New Revision: cdc52dc62a91bf7637827ddd3e50eaa842a00bd8
  https://github.com/droonga/fluent-plugin-droonga/commit/cdc52dc62a91bf7637827ddd3e50eaa842a00bd8

  Message:
    Add test for GrongaCommandConverter with a sample test
    
    More test must to be added.

  Added files:
    test/test_groonga_command_converter.rb

  Added: test/test_groonga_command_converter.rb (+75 -0) 100644
===================================================================
--- /dev/null
+++ test/test_groonga_command_converter.rb    2013-09-12 12:44:37 +0900 (2bb56cc)
@@ -0,0 +1,75 @@
+# Copyright (C) 2013 droonga project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+require "droonga/groonga_command_converter"
+
+class GroongaCommandConverterTest < Test::Unit::TestCase
+  def setup
+    @converter = Droonga::GroongaCommandConverter.new(:id => "test",
+                                                      :date => default_date,
+                                                      :reply_to => default_reply_to,
+                                                      :status_code => default_status_code,
+                                                      :dataset => default_dataset)
+  end
+
+  def test_table_create
+    results = []
+    command = "table_create Term TABLE_PAT_KEY ShortText " +
+                "--default_tokenizer TokenBigram --normalizer NormalizerAuto"
+    @converter.convert(command) do |droonga_command|
+      results << droonga_command
+    end
+    assert_equal([
+                   {
+                     :id => "test:0",
+                     :date => default_formatted_date,
+                     :replyTo => default_reply_to,
+                     :statusCode => default_status_code,
+                     :dataset => default_dataset,
+                     :type => "table_create",
+                     :body => {
+                       :name => "Term",
+                       :flags => "TABLE_PAT_KEY",
+                       :key_type => "ShortText",
+                       :value_type => nil,
+                       :default_tokenizer => "TokenBigram",
+                       :normalizer => "NormalizerAuto",
+                     },
+                   },
+                 ],
+                 results)
+  end
+
+  private
+  def default_date
+    Time.new(2013, 11, 29, 0, 0, 0)
+  end
+
+  def default_formatted_date
+    "2013-11-29T00:00:00+09:00"
+  end
+
+  def default_reply_to
+    "localhost:20033"
+  end
+
+  def default_status_code
+    200
+  end
+
+  def default_dataset
+    "test-dataset"
+  end
+end
-------------- next part --------------
HTML����������������������������...
Download 



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