Welcome to mirror list, hosted at ThFree Co, Russian Federation.

backfill_imported_issue_search_data_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0b4b1aabd8e5f566d7ff94aad4eed324d6617969 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe BackfillImportedIssueSearchData do
  let_it_be(:batched_migration) { described_class::MIGRATION }

  context 'when BackfillIssueSearchData.max_value is nil' do
    it 'schedules a new batched migration with a default max_value' do
      reversible_migration do |migration|
        migration.before -> {
          expect(batched_migration).not_to have_scheduled_batched_migration
        }

        migration.after -> {
          expect(batched_migration).to have_scheduled_batched_migration(
            table_name: :issues,
            column_name: :id,
            interval: described_class::DELAY_INTERVAL,
            batch_min_value: described_class::BATCH_MIN_VALUE
          )
        }
      end
    end
  end

  context 'when BackfillIssueSearchData.max_value exists' do
    before do
      Gitlab::Database::BackgroundMigration::BatchedMigration
        .create!(
          max_value: 200,
          batch_size: 200,
          sub_batch_size: 20,
          interval: 120,
          job_class_name: 'BackfillIssueSearchData',
          table_name: 'issues',
          column_name: 'id',
          gitlab_schema: 'glschema'
        )
    end

    it 'schedules a new batched migration with a custom max_value' do
      reversible_migration do |migration|
        migration.after -> {
          expect(batched_migration).to have_scheduled_batched_migration(
            table_name: :issues,
            column_name: :id,
            interval: described_class::DELAY_INTERVAL,
            batch_min_value: 200
          )
        }
      end
    end
  end
end