|
12 | 12 | let(:miq_task) { FactoryBot.create(:miq_task) }
|
13 | 13 | let(:manager) { FactoryBot.create(:automation_manager_ansible_tower) }
|
14 | 14 | let(:template) { FactoryBot.create(:ansible_configuration_script, :manager => manager) }
|
| 15 | + let(:workflow_template) { FactoryBot.create(:ansible_configuration_workflow, :manager => manager) } |
15 | 16 |
|
16 | 17 | let(:workspace) do
|
17 | 18 | double("MiqAeEngine::MiqAeWorkspaceRuntime", :root => root_object,
|
|
106 | 107 | end
|
107 | 108 | end
|
108 | 109 |
|
109 |
| - context "regular method" do |
| 110 | + context "regular method with jobs" do |
110 | 111 | before do
|
111 | 112 | allow(described_class::TEMPLATE_CLASS).to receive(:find).and_return(template)
|
112 | 113 | allow(template).to receive(:run_with_miq_job).and_return(miq_task.id)
|
|
133 | 134 | expect { aw.reload }.to raise_exception(ActiveRecord::RecordNotFound)
|
134 | 135 | end
|
135 | 136 |
|
136 |
| - it "template launch fails" do |
| 137 | + it "job template launch fails" do |
137 | 138 | expect(template).to receive(:run_with_miq_job).and_raise("Bamm Bamm Rubble")
|
138 | 139 |
|
139 | 140 | at = described_class.new(aem, obj, inputs)
|
|
142 | 143 | end
|
143 | 144 | end
|
144 | 145 |
|
| 146 | + context "regular method with workflows" do |
| 147 | + before do |
| 148 | + allow(described_class::TEMPLATE_CLASS).to receive(:find).and_return(workflow_template) |
| 149 | + allow(workflow_template).to receive(:run_with_miq_job).and_return(miq_task.id) |
| 150 | + allow(MiqRegion).to receive(:my_region).and_return(FactoryBot.create(:miq_region)) |
| 151 | + allow(AutomateWorkspace).to receive(:create).and_return(aw) |
| 152 | + allow(MiqTask).to receive(:wait_for_taskid).and_return(miq_task) |
| 153 | + allow(workspace).to receive(:update_workspace) |
| 154 | + end |
| 155 | + |
| 156 | + it "success" do |
| 157 | + miq_task.update_status(MiqTask::STATE_FINISHED, MiqTask::STATUS_OK, "Done") |
| 158 | + |
| 159 | + at = described_class.new(aem, obj, inputs) |
| 160 | + at.run |
| 161 | + |
| 162 | + expect { aw.reload }.to raise_exception(ActiveRecord::RecordNotFound) |
| 163 | + end |
| 164 | + |
| 165 | + it "method fails" do |
| 166 | + miq_task.update_status(MiqTask::STATE_FINISHED, MiqTask::STATUS_ERROR, "Done") |
| 167 | + |
| 168 | + at = described_class.new(aem, obj, inputs) |
| 169 | + expect { at.run }.to raise_exception(MiqAeException::Error) |
| 170 | + expect { aw.reload }.to raise_exception(ActiveRecord::RecordNotFound) |
| 171 | + end |
| 172 | + |
| 173 | + it "workflow template launch fails" do |
| 174 | + expect(workflow_template).to receive(:run_with_miq_job).and_raise("Bamm Bamm Rubble") |
| 175 | + |
| 176 | + at = described_class.new(aem, obj, inputs) |
| 177 | + expect { at.run }.to raise_exception(MiqAeException::Error) |
| 178 | + expect { aw.reload }.to raise_exception(ActiveRecord::RecordNotFound) |
| 179 | + end |
| 180 | + end |
| 181 | + |
145 | 182 | context "state machine" do
|
146 | 183 | before do
|
147 | 184 | root_hash['ae_state_started'] = Time.zone.now.utc.to_s
|
|
0 commit comments