From 1e8de1b694c5ef42f5553f3a9bcd0989536c6127 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Mon, 21 Oct 2024 13:48:03 -0400 Subject: [PATCH] Add an embedded_terraform_job FactoryBot factory --- spec/factories/job.rb | 8 ++++++++ .../automation_manager/stack_spec.rb | 18 ++---------------- 2 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 spec/factories/job.rb diff --git a/spec/factories/job.rb b/spec/factories/job.rb new file mode 100644 index 0000000..4ee3d15 --- /dev/null +++ b/spec/factories/job.rb @@ -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 diff --git a/spec/models/manageiq/providers/embedded_terraform/automation_manager/stack_spec.rb b/spec/models/manageiq/providers/embedded_terraform/automation_manager/stack_spec.rb index 6c8447c..49fde03 100644 --- a/spec/models/manageiq/providers/embedded_terraform/automation_manager/stack_spec.rb +++ b/spec/models/manageiq/providers/embedded_terraform/automation_manager/stack_spec.rb @@ -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) } @@ -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"