Skip to content

Commit

Permalink
Merge pull request #80 from agrare/use_job_factory
Browse files Browse the repository at this point in the history
Add an embedded_terraform_job FactoryBot factory
  • Loading branch information
Fryguy authored Oct 22, 2024
2 parents 2f44806 + 1e8de1b commit 337fcfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
8 changes: 8 additions & 0 deletions spec/factories/job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FactoryBot.define do
factory :embedded_terraform_job,
:parent => :job,
:class => "ManageIQ::Providers::EmbeddedTerraform::AutomationManager::Job" do
options { {} }
state { "waiting_to_start" }
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,7 @@
end
let(:miq_task) { FactoryBot.create(:miq_task, :job => job) }

let(:job) do
ManageIQ::Providers::EmbeddedTerraform::AutomationManager::Job.create_job(template, {}, {}, []).tap do |job|
job.state = "finished"
job.options = {
:terraform_stack_id => hello_world_retrieve_response['stack_id']
}
end
end

let(:job) { FactoryBot.create(:embedded_terraform_job, :state => "finished", :options => {:terraform_stack_id => hello_world_retrieve_response['stack_id']})}
let(:terraform_runner_stdout) { hello_world_retrieve_response['message'] }
let(:terraform_runner_stdout_html) { TerminalToHtml.render(terraform_runner_stdout) }

Expand Down Expand Up @@ -118,13 +110,7 @@
end

context "when miq_task.job.options present but missing terraform_stack_id" do
let(:job) do
ManageIQ::Providers::EmbeddedTerraform::AutomationManager::Job.create_job(template, {}, {}, []).tap do |job|
job.state = "waiting_to_start"
job.options = {}
end
end

let(:job) { FactoryBot.create(:embedded_terraform_job) }
let(:miq_task) { FactoryBot.create(:miq_task, :job => job) }

it_behaves_like "terraform runner stdout not available from miq_task"
Expand Down

0 comments on commit 337fcfd

Please sign in to comment.