Skip to content

Commit

Permalink
Fix CI test
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusbv committed Nov 26, 2024
1 parent f544bb0 commit a07a6d3
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
end

context 'when verification provider returns false' do
# let(:plugin_double) { instance_double('InstanceVerification::Providers::Example') }
let(:plugin_double) { instance_double('InstanceVerification::Providers::Example') }

before do
stub_request(:post, scc_activate_url)
Expand All @@ -80,8 +80,9 @@
body: { error: 'Unexpected instance verification error has occurred' }.to_json,
headers: {}
)
# allow(InstanceVerification::Providers::Example).to receive(:new).and_return(plugin_double)
# allow(plugin_double).to receive(:allowed_extension?).and_return(true)
allow(InstanceVerification::Providers::Example).to receive(:new).and_return(plugin_double)
allow_any_instance_of(InstanceVerification::Providers::Example).to receive(:allowed_extension?).and_return(true)
allow(plugin_double).to receive(:instance_valid?).and_return(false)
post url, params: payload, headers: headers
end

Expand Down Expand Up @@ -147,6 +148,7 @@
expect(InstanceVerification::Providers::Example).to receive(:new)
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
expect(plugin_double).to receive(:instance_valid?).and_return(false)
allow_any_instance_of(InstanceVerification::Providers::Example).to receive(:allowed_extension?).and_return(true)
post url, params: payload, headers: headers
end

Expand All @@ -161,6 +163,7 @@
expect(InstanceVerification::Providers::Example).to receive(:new)
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
expect(plugin_double).to receive(:instance_valid?).and_raise('Custom plugin error')
allow(plugin_double).to receive(:allowed_extension?).and_return(true)
post url, params: payload, headers: headers
end

Expand All @@ -177,7 +180,7 @@
expect(InstanceVerification::Providers::Example).to receive(:new)
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
expect(plugin_double).to receive(:instance_valid?).and_raise(InstanceVerification::Exception, 'Custom plugin error')

allow(plugin_double).to receive(:allowed_extension?).and_return(true)
post url, params: payload, headers: headers
end

Expand Down Expand Up @@ -231,8 +234,7 @@
end

before do
allow(InstanceVerification::Providers::Example).to receive(:new)
.with(nil, nil, nil, instance_data).and_return(plugin_double)
allow(InstanceVerification::Providers::Example).to receive(:new).and_return(plugin_double)
allow(plugin_double).to receive(:parse_instance_data).and_return({ InstanceId: 'foo' })

FactoryBot.create(:subscription, product_classes: product_classes)
Expand Down Expand Up @@ -403,7 +405,7 @@
.to_return(status: 201, body: scc_response_body, headers: {})

expect(InstanceVerification).not_to receive(:update_cache).with('127.0.0.1', system.login, product.id)

allow(plugin_double).to receive(:allowed_extension?).and_return(true)
post url, params: payload_no_token, headers: headers
end

Expand All @@ -415,6 +417,10 @@
end

context 'when the system is hybrid' do
before do
allow_any_instance_of(InstanceVerification::Providers::Example).to receive(:allowed_extension?).and_return(true)
end

context "when system doesn't have hw_info" do
let(:system) { FactoryBot.create(:system, :hybrid) }

Expand Down

0 comments on commit a07a6d3

Please sign in to comment.