Skip to content

Commit

Permalink
[EmbeddedAnsible] Remove TODOs from job_spec.rb
Browse files Browse the repository at this point in the history
Uncomments a few tests that just work, and removes the ones that are no
longer relevant or tested elsewhere.
  • Loading branch information
NickLaMuro committed Sep 20, 2019
1 parent 69d5c32 commit 9c11580
Showing 1 changed file with 30 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,6 @@
# expect(subject.parameters.first).to have_attributes(:name => "param1", :value => "val1")
#
end

# TODO: This is should be irrelevant now, right?
# it "catches errors from provider" do
# expect(connection.api.jobs).to receive(:find).and_raise("bad request")
# expect { subject.refresh_ems }.to raise_error(MiqException::MiqOrchestrationUpdateError)
# end
end
end

Expand All @@ -177,53 +171,36 @@
end
end

# TODO: Punting for now need some more time to get this tested properly,
# but don't have the current mental capacity to figure the right way
# to set this up in a time crunch.

# describe "#raw_stdout" do
# subject { described_class.create_job(template, {}) }

# it "gets the standard output of the job" do
# expect(subject.raw_stdout("html")).to eq("<html><body>job stdout</body></html>")
# end

# it "catches errors from provider" do
# expect(connection.api.jobs).to receive(:find).and_raise("bad happened")
# expect { subject.raw_stdout("html") }.to raise_error(MiqException::MiqOrchestrationStatusError)
# end
# end
#
# describe "#raw_stdout_via_worker" do
# before do
# EvmSpecHelper.create_guid_miq_server_zone
# allow(described_class).to receive(:find).and_return(job)

# allow(MiqTask).to receive(:wait_for_taskid) do
# request = MiqQueue.find_by(:class_name => described_class.name)
# request.update(:state => MiqQueue::STATE_DEQUEUE)
# request.delivered(*request.deliver)
# end
# end

# it "gets stdout from the job" do
# expect(job).to receive(:raw_stdout).and_return("A stdout from the job")
# taskid = job.raw_stdout_via_worker("user")
# MiqTask.wait_for_taskid(taskid)
# expect(MiqTask.find(taskid)).to have_attributes(
# :task_results => "A stdout from the job",
# :status => "Ok"
# )
# end

# it "returns the error message" do
# expect(job).to receive(:raw_stdout).and_throw("Failed to get stdout from the job")
# taskid = job.raw_stdout_via_worker("user")
# MiqTask.wait_for_taskid(taskid)
# expect(MiqTask.find(taskid).message).to include("Failed to get stdout from the job")
# expect(MiqTask.find(taskid).status).to eq("Error")
# end
# end
describe "#raw_stdout_via_worker" do
before do
EvmSpecHelper.create_guid_miq_server_zone
allow(described_class).to receive(:find).and_return(job)

allow(MiqTask).to receive(:wait_for_taskid) do
request = MiqQueue.find_by(:class_name => described_class.name)
request.update_attributes(:state => MiqQueue::STATE_DEQUEUE)
request.delivered(*request.deliver)
end
end

it "gets stdout from the job" do
expect(job).to receive(:raw_stdout).and_return("A stdout from the job")
taskid = job.raw_stdout_via_worker("user")
MiqTask.wait_for_taskid(taskid)
expect(MiqTask.find(taskid)).to have_attributes(
:task_results => "A stdout from the job",
:status => "Ok"
)
end

it "returns the error message" do
expect(job).to receive(:raw_stdout).and_throw("Failed to get stdout from the job")
taskid = job.raw_stdout_via_worker("user")
MiqTask.wait_for_taskid(taskid)
expect(MiqTask.find(taskid).message).to include("Failed to get stdout from the job")
expect(MiqTask.find(taskid).status).to eq("Error")
end
end
end

context "when embedded_ansible role is disabled" do
Expand Down

0 comments on commit 9c11580

Please sign in to comment.