diff --git a/spec/models/manageiq/providers/embedded_ansible/automation_manager/job/status_spec.rb b/spec/models/manageiq/providers/embedded_ansible/automation_manager/job/status_spec.rb index 8fb4ae460af..a6a45173d5b 100644 --- a/spec/models/manageiq/providers/embedded_ansible/automation_manager/job/status_spec.rb +++ b/spec/models/manageiq/providers/embedded_ansible/automation_manager/job/status_spec.rb @@ -31,18 +31,6 @@ expect(status.normalized_status).to eq(['failed', 'Stack creation failed']) end - # TODO: remove or implement? Is canceling something we can handle? - # - # it 'parses Canceled' do - # status = described_class.new('Canceled', nil) - # expect(status.completed?).to be_truthy - # expect(status.succeeded?).to be_falsey - # expect(status.canceled?).to be_truthy - # expect(status.deleted?).to be_falsey - # expect(status.rolled_back?).to be_falsey - # expect(status.normalized_status).to eq(['create_canceled', 'Job launching was canceled']) - # end - it 'parses transient status' do miq_task.state = MiqTask::STATE_ACTIVE miq_task.status = MiqTask::STATUS_UNKNOWN diff --git a/spec/models/manageiq/providers/embedded_ansible/automation_manager/job_spec.rb b/spec/models/manageiq/providers/embedded_ansible/automation_manager/job_spec.rb index 9433d2aecf4..b9fab33f33a 100644 --- a/spec/models/manageiq/providers/embedded_ansible/automation_manager/job_spec.rb +++ b/spec/models/manageiq/providers/embedded_ansible/automation_manager/job_spec.rb @@ -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("job stdout") - # 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