Commit ab6286cb authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'mo-add-pending-running-builds-factory' into 'master'

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

See merge request gitlab-org/gitlab!64223
parents 563396e6 21f8e4ba
# 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
context 'when there is a queuing entry already present' do
before do
::Ci::PendingBuild.create!(build: build, project: build.project)
create(:ci_pending_build, build: build, project: build.project)
end
it 'does not raise an error' do
......@@ -396,7 +396,7 @@ RSpec.describe Ci::Build do
context 'when both failure scenario happen at the same time' do
before do
::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
it 'raises stale object error exception' do
......@@ -478,7 +478,7 @@ RSpec.describe Ci::Build do
let(:build) { create(:ci_build, :pending) }
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)
end
......
......@@ -20,7 +20,7 @@ RSpec.describe Ci::PendingBuild do
context 'when another queuing entry exists for given build' do
before do
described_class.create!(build: build, project: project, protected: false)
create(:ci_pending_build, build: build, project: project)
end
it 'returns a build id as a result' do
......
......@@ -21,10 +21,7 @@ RSpec.describe Ci::RunningBuild do
context 'when another queuing entry exists for given build' do
before do
described_class.create!(build: build,
project: project,
runner: runner,
runner_type: runner.runner_type)
create(:ci_running_build, build: build, project: project, runner: runner)
end
it 'returns a build id as a result' do
......
......@@ -45,7 +45,7 @@ RSpec.describe Ci::UpdateBuildQueueService do
context 'when duplicate entry exists' do
before do
::Ci::PendingBuild.create!(build: build, project: project)
create(:ci_pending_build, build: build, project: build.project)
end
it 'does nothing and returns build id' do
......@@ -66,7 +66,7 @@ RSpec.describe Ci::UpdateBuildQueueService do
context 'when pending build exists' do
before do
Ci::PendingBuild.create!(build: build, project: project)
create(:ci_pending_build, build: build, project: build.project)
end
it 'removes pending build in a transaction' do
......@@ -146,9 +146,7 @@ RSpec.describe Ci::UpdateBuildQueueService do
context 'when duplicate entry exists' do
before do
::Ci::RunningBuild.create!(
build: build, project: project, runner: runner, runner_type: runner.runner_type
)
create(:ci_running_build, build: build, project: project, runner: runner)
end
it 'does nothing and returns build id' do
......@@ -169,9 +167,7 @@ RSpec.describe Ci::UpdateBuildQueueService do
context 'when shared runner build tracking entry exists' do
before do
Ci::RunningBuild.create!(
build: build, project: project, runner: runner, runner_type: runner.runner_type
)
create(:ci_running_build, build: build, project: project, runner: runner)
end
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