Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #494 from Shopify/abort-on-partners-error
Browse files Browse the repository at this point in the history
Abort when rescuing 404 from parters in authenticated_req
  • Loading branch information
jacobsteves authored Mar 31, 2020
2 parents 7cdb93f + fa7bc28 commit c0e6b16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/shopify-cli/helpers/partners_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def authenticated_req(ctx)
Tasks::AuthenticateIdentity.call(ctx)
retry
rescue API::APIRequestNotFoundError
ctx.puts("{{x}} error: Your account was not found. Please sign up at https://partners.shopify.com/signup")
ctx.error("error: Your account was not found. Please sign up at https://partners.shopify.com/signup")
end

def api_client(ctx)
Expand Down
11 changes: 7 additions & 4 deletions test/shopify-cli/helpers/partners_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,21 @@ def test_query_can_reauth
PartnersAPI.query(@context, 'query')
end

def test_query_fails_gracefully_without_partners_account
def test_query_aborts_without_partners_account
api_stub = Object.new
PartnersAPI.expects(:new).with(
ctx: @context,
token: 'token123',
url: "#{PartnersAPI.endpoint}/api/cli/graphql",
).returns(api_stub)
api_stub.expects(:query).raises(API::APIRequestNotFoundError)
@context.expects(:puts).with(
"{{x}} error: Your account was not found. Please sign up at https://partners.shopify.com/signup",
e = assert_raises ShopifyCli::Abort do
PartnersAPI.query(@context, 'query')
end
assert_match(
'error: Your account was not found. Please sign up at https://partners.shopify.com/signup',
e.message
)
PartnersAPI.query(@context, 'query')
end

def test_query
Expand Down

0 comments on commit c0e6b16

Please sign in to comment.