Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanensari committed Dec 20, 2024
1 parent d6ce7fb commit 32a3a9f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

require "minitest/autorun"
require "vcr"
require "webmock/minitest"

VCR.configure do |c|
c.hook_into(:webmock)
Expand Down
14 changes: 12 additions & 2 deletions test/peddler/api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ def test_rate_limit_noop
end

def test_rate_limit
skip("HTTP doesn't implement retriable") unless @api.http.respond_to?(:retriable)
@api.meter(1.0)

assert_kind_of(HTTP::Client, @api.http)

@api.stub(:retries, 1) do
@api.meter(1.0)

assert_kind_of(HTTP::Retriable::Client, @api.http)
if @api.http.respond_to?(:retriable)
assert_kind_of(HTTP::Retriable::Client, @api.http)
else
assert_kind_of(HTTP::Client, @api.http)
end
end
end

Expand Down Expand Up @@ -121,5 +124,12 @@ def perform_must_sandbox_operation
test_api.perform_must_sandbox_operation
end
end

def test_parser
parser = ->(response) { JSON.parse(response.body.to_s) }
@api.parser = parser

assert_equal(parser, @api.parser)
end
end
end
35 changes: 35 additions & 0 deletions test/peddler/helpers/feeds_2021_06_30_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require "helper"
require "peddler/helpers/feeds_2021_06_30"

module Peddler
module Helpers
class Feeds20210630Test < Minitest::Test
include Feeds20210630

def test_upload_feed_document_success
stub_request(:put, /.*/)
.to_return(status: 200, body: "", headers: {})

res = upload_feed_document("https://example.com", "content", "text/plain")

assert_predicate(res.status, :ok?)
end

def test_upload_feed_document_client_error
stub_request(:put, /.*/)
.to_return(status: 400,
body: {
"errors" => [{
"code" => "Error",
}],
}.to_json)

assert_raises(Peddler::Error) do
upload_feed_document("https://example.com", "content", "text/plain")
end
end
end
end
end
4 changes: 4 additions & 0 deletions test/peddler/marketplace_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def test_all
assert(Marketplace.all)
end

def test_to_str
assert_equal(@marketplace.id, @marketplace.to_str)
end

private

def country_code
Expand Down
6 changes: 6 additions & 0 deletions test/peddler/token_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def test_grant_type_with_refresh_token
assert_equal("refresh_token", token.grant_type)
end

def test_explicit_grant_type
token = Token.new(grant_type: "let_me_in")

assert_equal("let_me_in", token.grant_type)
end

private

def scope
Expand Down

0 comments on commit 32a3a9f

Please sign in to comment.