null+****@clear*****
null+****@clear*****
2010年 11月 23日 (火) 22:09:38 JST
Kouhei Sutou 2010-11-23 13:09:38 +0000 (Tue, 23 Nov 2010)
New Revision: dfb6fb88f83b394bb7a69389485153b4c905c39f
Log:
add a test for test_http.
Modified files:
test/unit/grntest/test-out-http.rb
Modified: test/unit/grntest/test-out-http.rb (+38 -0)
===================================================================
--- test/unit/grntest/test-out-http.rb 2010-11-23 13:09:27 +0000 (c1a9fad)
+++ test/unit/grntest/test-out-http.rb 2010-11-23 13:09:38 +0000 (cc41df1)
@@ -53,4 +53,42 @@ class GrnTestOutHTTPTest < Test::Unit::TestCase
["広瀬屋"]]]],
[status[0], result])
end
+
+ def test_test_http
+ command = 'select Shops --sortby _id --limit 5 --output_columns "name"'
+ command_file = tempfile("command") do |file|
+ file.puts(command)
+ end
+ expected =
+ '[[0,1290511592.67556,0.00068249],' +
+ '[[[36],' +
+ '[["name","ShortText"]],' +
+ '["根津のたいやき"],' +
+ '["たい焼 カタオカ"],' +
+ '["そばたいやき空"],' +
+ '["車"],' +
+ '["広瀬屋"]]]]'
+ expected_file = tempfile("expected") do |file|
+ file.puts(expected)
+ end
+ script_file = tempfile("script") do |file|
+ file.puts("test_http #{command_file.path} #{expected_file.path}")
+ end
+ output, error, status = invoke_grntest("--noftp",
+ "--groonga", groonga,
+ "--protocol", "http",
+ "--log-output-dir", @tmp_dir,
+ script_file.path, @database_path)
+ assert_predicate(status, :success?, [output, error])
+ assert_equal("DIFF:command:#{command}\n" +
+ "DIFF:result:#{normalize_result(expected)}\n" +
+ "DIFF:expect:#{normalize_result(expected)}\n" +
+ "\n",
+ normalize_result(File.read("#{expected_file.path}.diff")))
+ end
+
+ private
+ def normalize_result(result)
+ result.gsub(/\[\[0,[\d.]+,[\d.]+\],/, '[[0,0.0,0.0],')
+ end
end