Skip to content

Commit

Permalink
Test for silent_reg_code_mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Jan 18, 2018
1 parent 08a0193 commit e5c325d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/connect_helpers_spec.rb
Expand Up @@ -4,7 +4,7 @@
require "registration/connect_helpers"

# helper for creating the SCC API error exceptions
def api_error(code: 400, headers: {}, body: "")
def api_error(code: 400, headers: {}, body: {})
SUSE::Connect::ApiError.new(
OpenStruct.new(
code: code,
Expand Down Expand Up @@ -123,6 +123,21 @@ def api_error(code: 400, headers: {}, body: "")
end
end

context "'silent_reg_code_mismatch' parameter is set and a mismatch error occurs" do
before do
allow(Registration::UrlHelpers).to receive(:registration_url)
.and_return(SUSE::Connect::YaST::DEFAULT_URL)
end

it "does not report an error and returns false" do
msg = "Subscription does not include the requested product 'Free Beer'"
exception = api_error(code: 422, body: {"localized_error" => msg})

expect(Yast::Report).to_not receive(:Error)
expect(helpers.catch_registration_errors(silent_reg_code_mismatch: true) { raise exception }).to eq(false)
end
end

context "'show_update_hint' parameter is set to true and error 401 is raised" do
let(:exception) { api_error(code: 401) }

Expand Down

0 comments on commit e5c325d

Please sign in to comment.