[Groonga-commit] groonga/groonga [master] [http] add a test for content-type on error. fixes #1220

Back to archive index

null+****@clear***** null+****@clear*****
2011年 12月 19日 (月) 14:15:20 JST


Kouhei Sutou	2011-12-19 05:15:20 +0000 (Mon, 19 Dec 2011)

  New Revision: 7f2bbc8cb2e3f73c88b8c63a68d52d9ecf64916e

  Log:
    [http] add a test for content-type on error. fixes #1220

  Modified files:
    test/unit/http/test-http.rb

  Modified: test/unit/http/test-http.rb (+22 -0)
===================================================================
--- test/unit/http/test-http.rb    2011-12-19 04:53:01 +0000 (b647f47)
+++ test/unit/http/test-http.rb    2011-12-19 05:15:20 +0000 (8564d52)
@@ -64,6 +64,28 @@ module HTTPTests
       get(command_path(:shutdown, :output_type => output_type))
     end
   end
+
+  def test_nonexistent
+    response = get(command_path(:nonexistent, :output_type => output_type))
+    assert_equal(content_type, response.content_type)
+    error_response = parse(response.body)
+    error_response[0][1] = 0.0
+    error_response[0][2] = 0.0
+    if error_response[0][4]
+      backtrace = error_response[0][4][0]
+      backtrace[0] = "function" if backtrace[0].is_a?(String)
+      backtrace[1] = "file.c" if backtrace[1].is_a?(String)
+      backtrace[2] = 29 if backtrace[2].is_a?(Integer)
+    end
+    path = "#{document_root}/d/nonexistent"
+    path << ".#{output_type}" if output_type
+    assert_equal([[Result::NO_SUCH_FILE_OR_DIRECTORY,
+                   0.0,
+                   0.0,
+                   "no such file: <#{path}>",
+                   [["function", "file.c", 29]]]],
+                 error_response)
+  end
 end
 
 class JSONHTTPTest < Test::Unit::TestCase




Groonga-commit メーリングリストの案内
Back to archive index