Kouhei Sutou
kou****@clear*****
Thu Sep 12 12:55:37 JST 2013
> にした方が未投資がよくなりますよ。 おぉ。。。何をしたいんだ。。。 In <20130912.125447.2071569443879475227.kou �� clear-code.com> "Re: [Groonga-commit] droonga/fluent-plugin-droonga �� cdc52dc [master] Add test for GrongaCommandConverter with a sample test" on Thu, 12 Sep 2013 12:54:47 +0900 (JST), Kouhei Sutou <kou �� clear-code.com> wrote: >> + @converter = Droonga::GroongaCommandConverter.new(:id => "test", >> + :date => default_date, >> + :reply_to => default_reply_to, >> + :status_code => default_status_code, >> + :dataset => default_dataset) > > だいぶ横に長いので > > options = { > :id => "test", > :date => default_date, > :reply_to => default_reply_to, > :status_code => default_status_code, > :dataset => default_dataset, > } > @converter = Droonga::GroongaCommandConverter.new(options) > > にした方が未投資がよくなりますよ。 > > あと、 > >> + def default_date >> + Time.new(2013, 11, 29, 0, 0, 0) >> + end > > こいつらは、「default_」なしでいいと思います。カスタマイズし > ないと思うので。 > > もし、カスタマイズしたくなったら、サブテストケースを作るのが > よいと思います。同じテストケースの中に違う初期化が必要なやつ > があると、ごちゃごちゃしてメンテナンスしづらくなるんですよ。 > あるテストのために初期化を変えたら他のテストにも影響があって > うわーとかなったり。 > > サブテストケースの作り方は↓らへんを読むとわかると思います。 > > http://www.clear-code.com/blog/2012/4/25.html > > In <cdc52dc62a91bf7637827ddd3e50eaa842a00bd8 �� jenkins.clear-code.com> > "[Groonga-commit] droonga/fluent-plugin-droonga �� cdc52dc [master] Add test for GrongaCommandConverter with a sample test" on Thu, 12 Sep 2013 12:44:37 +0900, > YUKI Hiroshi <null+groonga �� clear-code.com> wrote: > >> 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 > > _______________________________________________ > Groonga-commit mailing list > Groonga-commit �� lists.sourceforge.jp > http://lists.sourceforge.jp/mailman/listinfo/groonga-commit