debian-mirror-gitlab/spec/migrations/20220128155251_remove_dangling_running_builds_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.4 KiB
Ruby
Raw Normal View History

2022-04-04 11:22:00 +05:30
# frozen_string_literal: true
require 'spec_helper'
require_migration!('remove_dangling_running_builds')
2022-08-27 11:52:29 +05:30
RSpec.describe RemoveDanglingRunningBuilds, :suppress_gitlab_schemas_validate_connection do
2022-04-04 11:22:00 +05:30
let(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') }
let(:project) { table(:projects).create!(namespace_id: namespace.id) }
let(:runner) { table(:ci_runners).create!(runner_type: 1) }
let(:builds) { table(:ci_builds) }
let(:running_builds) { table(:ci_running_builds) }
let(:running_build) do
builds.create!(
name: 'test 1',
status: 'running',
project_id: project.id,
type: 'Ci::Build')
end
let(:failed_build) do
builds.create!(
name: 'test 2',
status: 'failed',
project_id: project.id,
type: 'Ci::Build')
end
let!(:running_metadata) do
running_builds.create!(
build_id: running_build.id,
project_id: project.id,
runner_id: runner.id,
runner_type:
runner.runner_type)
end
let!(:failed_metadata) do
running_builds.create!(
build_id: failed_build.id,
project_id: project.id,
runner_id: runner.id,
runner_type: runner.runner_type)
end
it 'removes failed builds' do
migrate!
expect(running_metadata.reload).to be_present
2022-08-27 11:52:29 +05:30
expect { failed_metadata.reload }.to raise_error(ActiveRecord::RecordNotFound)
2022-04-04 11:22:00 +05:30
end
end