debian-mirror-gitlab/spec/lib/gitlab/database/reindexing_spec.rb

33 lines
1,000 B
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Database::Reindexing do
include ExclusiveLeaseHelpers
describe '.perform' do
subject { described_class.perform(indexes) }
let(:coordinator) { instance_double(Gitlab::Database::Reindexing::Coordinator) }
let(:indexes) { double }
it 'delegates to Coordinator' do
expect(Gitlab::Database::Reindexing::Coordinator).to receive(:new).with(indexes).and_return(coordinator)
expect(coordinator).to receive(:perform)
subject
end
end
describe '.candidate_indexes' do
subject { described_class.candidate_indexes }
it 'retrieves regular indexes that are no left-overs from previous runs' do
result = double
2021-01-29 00:20:46 +05:30
expect(Gitlab::Database::PostgresIndex).to receive_message_chain('regular.where.not_match.not_match').with(no_args).with('NOT expression').with('^tmp_reindex_').with('^old_reindex_').and_return(result)
2021-01-03 14:25:43 +05:30
expect(subject).to eq(result)
end
end
end