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

20211110143306_add_not_null_constraint_to_security_findings_uuid_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3b69169b2d6af75e5ef237d1512be5ac145f4486 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true
require 'spec_helper'
require_migration!

RSpec.describe AddNotNullConstraintToSecurityFindingsUuid, feature_category: :vulnerability_management do
  let!(:security_findings) { table(:security_findings) }
  let!(:migration) { described_class.new }

  before do
    allow(migration).to receive(:transaction_open?).and_return(false)
    allow(migration).to receive(:with_lock_retries).and_yield
  end

  it 'adds a check constraint' do
    constraint = security_findings.connection.check_constraints(:security_findings).find { |constraint| constraint.expression == "uuid IS NOT NULL" }
    expect(constraint).to be_nil

    migration.up

    constraint = security_findings.connection.check_constraints(:security_findings).find { |constraint| constraint.expression == "uuid IS NOT NULL" }
    expect(constraint).to be_a(ActiveRecord::ConnectionAdapters::CheckConstraintDefinition)
  end
end