class TestHTTPError

Public Instance Methods

test_error_with_empty_message() click to toggle source
# File test/test_http_error.rb, line 25
def test_error_with_empty_message
  response = MockResponse.new(code=400, message="Meep",
                              headers={}, body="")
  err = SplunkHTTPError.new(response)
  assert_nil(err.detail)
  assert_equal(response.code, err.code)
  assert_equal(response.message, err.reason)
  assert_equal("HTTP 400 Meep: ", err.message)
end
test_error_with_message() click to toggle source
# File test/test_http_error.rb, line 35
def test_error_with_message
  response = MockResponse.new(
      code=400, message="Index Error", headers={},
      body = "<response><messages>" +
          "<msg type=\"ERROR\">In handler &apos;indexes&apos;: " +
          "Index name=boris already exists</msg></messages></response>")
  err = SplunkHTTPError.new(response)
  assert_equal("In handler 'indexes': Index name=boris already exists",
               err.detail)
  assert_equal(400, err.code)
  assert_equal("Index Error", err.reason)
  assert_equal([], err.headers)
  assert_equal("HTTP 400 Index Error: In handler 'indexes': " +
                   "Index name=boris already exists",
               err.message)
end