Skip to content

Commit

Permalink
Add 404 error
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanensari committed Oct 1, 2024
1 parent aff23a0 commit 240ae7d
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/peddler/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Peddler
class Error < StandardError
class InvalidInput < Error; end
class NotFound < Error; end
class QuotaExceeded < Error; end
class Unauthorized < Error; end

Expand Down
26 changes: 26 additions & 0 deletions test/peddler/error/not_found_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require "helper"

require "peddler/api/reports_2021_06_30"

module Peddler
class Error
class NotFoundTest < Minitest::Test
include FeatureHelpers

def test_not_found
error = assert_raises(NotFound) do
api.get_report("1234567")
end
assert_equal(404, error.cause.status)
end

private

def api_class
API::Reports20210630
end
end
end
end
7 changes: 7 additions & 0 deletions test/peddler/error_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ def test_invalid_input
assert_kind_of(Error::InvalidInput, error)
end

def test_not_found
response = '{"errors":[{"code":"NotFound","message":"NotFound"}]}'
error = Error.build(response)

assert_kind_of(Error::NotFound, error)
end

def test_quota_exceeded
response = '{"errors":[{"code":"QuotaExceeded","message":"You exceeded your quota for the requested resource."}]}'
error = Error.build(response)
Expand Down
111 changes: 111 additions & 0 deletions test/vcr_cassettes/Peddler/Error/NotFoundTest/test_not_found.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 240ae7d

Please sign in to comment.