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

foreign_key_spec.rb « schema_objects « schema_validation « database « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7500ad44f82f47391405c3a872a3f2c9547aaf3f (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Database::SchemaValidation::SchemaObjects::ForeignKey, feature_category: :database do
  subject(:foreign_key) { described_class.new(adapter) }

  let(:database_adapter) { 'Gitlab::Database::SchemaValidation::Adapters::ForeignKeyDatabaseAdapter' }
  let(:adapter) do
    instance_double(database_adapter, name: 'public.fk_1d37cddf91', table_name: 'vulnerabilities',
      statement: 'FOREIGN KEY (epic_id) REFERENCES epics(id) ON DELETE SET NULL')
  end

  describe '#name' do
    it { expect(foreign_key.name).to eq('public.fk_1d37cddf91') }
  end

  describe '#table_name' do
    it { expect(foreign_key.table_name).to eq('vulnerabilities') }
  end

  describe '#statement' do
    it { expect(foreign_key.statement).to eq('FOREIGN KEY (epic_id) REFERENCES epics(id) ON DELETE SET NULL') }
  end
end