Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the ems_event add_queue method #16187

Merged
merged 2 commits into from
Oct 12, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add spec tests for EmsEvent.add_queue
  • Loading branch information
agrare committed Oct 12, 2017
commit 0062162a5b3be56d5c291acc8df90b2275d22adc
49 changes: 49 additions & 0 deletions spec/models/ems_event_spec.rb
Original file line number Diff line number Diff line change
@@ -177,6 +177,55 @@
end
end

context ".add_queue" do
let(:ems) { FactoryGirl.create(:ems_kubernetes) }
let(:event_hash) do
{
:ems_ref => "event-ref",
:ems_id => ems.id,
:event_type => "STUFF_HAPPENED"
}
end

context "queue_type: artemis" do
before { stub_settings_merge(:prototype => {:queue_type => 'artemis'}) }

it "Adds event to Artemis queue" do
queue_client = double("ManageIQ::Messaging")

expected_queue_payload = {
:service => "events",
:sender => ems.id,
:event => event_hash[:event_type],
:payload => event_hash,
}

expect(queue_client).to receive(:publish_topic).with(expected_queue_payload)
expect(MiqQueue).to receive(:artemis_client).with('event_handler').and_return(queue_client)

described_class.add_queue('add', ems.id, event_hash)
end
end

context "queue_type: miq_queue" do
before { stub_settings_merge(:prototype => {:queue_type => 'miq_queue'}) }

it "Adds event to MiqQueue" do
expected_queue_payload = {
:service => "event",
:target_id => ems.id,
:class_name => described_class.name,
:method_name => 'add',
:args => [event_hash],
}

expect(MiqQueue).to receive(:submit_job).with(expected_queue_payload)

described_class.add_queue('add', ems.id, event_hash)
end
end
end

context ".add" do
before :each do
@event_hash = {