Commit 21f8e4ba authored by Maxime Orefice's avatar Maxime Orefice Committed by Grzegorz Bizon

Add factory for CI::PendingBuild and CI::RunningBuild

parent e67f5869
# frozen_string_literal: true
FactoryBot.define do
factory :ci_pending_build, class: 'Ci::PendingBuild' do
build factory: :ci_build
project
protected { build.protected }
end
end
# frozen_string_literal: true
FactoryBot.define do
factory :ci_running_build, class: 'Ci::RunningBuild' do
build factory: :ci_build
project
runner factory: :ci_runner
runner_type { runner.runner_type }
end
end
...@@ -384,7 +384,7 @@ RSpec.describe Ci::Build do ...@@ -384,7 +384,7 @@ RSpec.describe Ci::Build do
context 'when there is a queuing entry already present' do context 'when there is a queuing entry already present' do
before do before do
::Ci::PendingBuild.create!(build: build, project: build.project) create(:ci_pending_build, build: build, project: build.project)
end end
it 'does not raise an error' do it 'does not raise an error' do
...@@ -396,7 +396,7 @@ RSpec.describe Ci::Build do ...@@ -396,7 +396,7 @@ RSpec.describe Ci::Build do
context 'when both failure scenario happen at the same time' do context 'when both failure scenario happen at the same time' do
before do before do
::Ci::Build.find(build.id).update_column(:lock_version, 100) ::Ci::Build.find(build.id).update_column(:lock_version, 100)
::Ci::PendingBuild.create!(build: build, project: build.project) create(:ci_pending_build, build: build, project: build.project)
end end
it 'raises stale object error exception' do it 'raises stale object error exception' do
...@@ -478,7 +478,7 @@ RSpec.describe Ci::Build do ...@@ -478,7 +478,7 @@ RSpec.describe Ci::Build do
let(:build) { create(:ci_build, :pending) } let(:build) { create(:ci_build, :pending) }
before do before do
::Ci::PendingBuild.create!(build: build, project: build.project) create(:ci_pending_build, build: build, project: build.project)
::Ci::Build.find(build.id).update_column(:lock_version, 100) ::Ci::Build.find(build.id).update_column(:lock_version, 100)
end end
......
...@@ -20,7 +20,7 @@ RSpec.describe Ci::PendingBuild do ...@@ -20,7 +20,7 @@ RSpec.describe Ci::PendingBuild do
context 'when another queuing entry exists for given build' do context 'when another queuing entry exists for given build' do
before do before do
described_class.create!(build: build, project: project, protected: false) create(:ci_pending_build, build: build, project: project)
end end
it 'returns a build id as a result' do it 'returns a build id as a result' do
......
...@@ -21,10 +21,7 @@ RSpec.describe Ci::RunningBuild do ...@@ -21,10 +21,7 @@ RSpec.describe Ci::RunningBuild do
context 'when another queuing entry exists for given build' do context 'when another queuing entry exists for given build' do
before do before do
described_class.create!(build: build, create(:ci_running_build, build: build, project: project, runner: runner)
project: project,
runner: runner,
runner_type: runner.runner_type)
end end
it 'returns a build id as a result' do it 'returns a build id as a result' do
......
...@@ -45,7 +45,7 @@ RSpec.describe Ci::UpdateBuildQueueService do ...@@ -45,7 +45,7 @@ RSpec.describe Ci::UpdateBuildQueueService do
context 'when duplicate entry exists' do context 'when duplicate entry exists' do
before do before do
::Ci::PendingBuild.create!(build: build, project: project) create(:ci_pending_build, build: build, project: build.project)
end end
it 'does nothing and returns build id' do it 'does nothing and returns build id' do
...@@ -66,7 +66,7 @@ RSpec.describe Ci::UpdateBuildQueueService do ...@@ -66,7 +66,7 @@ RSpec.describe Ci::UpdateBuildQueueService do
context 'when pending build exists' do context 'when pending build exists' do
before do before do
Ci::PendingBuild.create!(build: build, project: project) create(:ci_pending_build, build: build, project: build.project)
end end
it 'removes pending build in a transaction' do it 'removes pending build in a transaction' do
...@@ -146,9 +146,7 @@ RSpec.describe Ci::UpdateBuildQueueService do ...@@ -146,9 +146,7 @@ RSpec.describe Ci::UpdateBuildQueueService do
context 'when duplicate entry exists' do context 'when duplicate entry exists' do
before do before do
::Ci::RunningBuild.create!( create(:ci_running_build, build: build, project: project, runner: runner)
build: build, project: project, runner: runner, runner_type: runner.runner_type
)
end end
it 'does nothing and returns build id' do it 'does nothing and returns build id' do
...@@ -169,9 +167,7 @@ RSpec.describe Ci::UpdateBuildQueueService do ...@@ -169,9 +167,7 @@ RSpec.describe Ci::UpdateBuildQueueService do
context 'when shared runner build tracking entry exists' do context 'when shared runner build tracking entry exists' do
before do before do
Ci::RunningBuild.create!( create(:ci_running_build, build: build, project: project, runner: runner)
build: build, project: project, runner: runner, runner_type: runner.runner_type
)
end end
it 'removes shared runner build' do it 'removes shared runner build' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment