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 Jun 15, 2020
1 parent f69fb33 commit 5dabc93
Showing 1 changed file with 30 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,53 +144,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(playbook, {}) }

# 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(: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 5dabc93

Please sign in to comment.