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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/database/dictionary_spec.rb')
-rw-r--r--spec/lib/gitlab/database/dictionary_spec.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/dictionary_spec.rb b/spec/lib/gitlab/database/dictionary_spec.rb
index 261cf27ed69..59145842b24 100644
--- a/spec/lib/gitlab/database/dictionary_spec.rb
+++ b/spec/lib/gitlab/database/dictionary_spec.rb
@@ -24,6 +24,25 @@ RSpec.describe Gitlab::Database::Dictionary, feature_category: :database do
end
end
+ describe '.any_entry' do
+ it 'loads an entry from any scope' do
+ expect(described_class.any_entry('ci_pipelines')).to be_present # Regular table
+ expect(described_class.any_entry('audit_events_archived')).to be_present # Deleted table
+ expect(described_class.any_entry('postgres_constraints')).to be_present # View
+ expect(described_class.any_entry('not_a_table_ever')).to be_nil
+ end
+ end
+
+ describe '.entry' do
+ it 'loads an Entry from the given scope' do
+ expect(described_class.entry('ci_pipelines')).to be_present # Regular table
+ expect(described_class.entry('audit_events_archived')).not_to be_present # Deleted table
+ expect(described_class.entry('postgres_constraints')).not_to be_present # Deleted table
+ expect(described_class.entry('audit_events_archived', 'deleted_tables')).to be_present # Deleted table
+ expect(described_class.entry('postgres_constraints', 'views')).to be_present # View
+ end
+ end
+
describe '::Entry' do
subject(:database_dictionary) { described_class::Entry.new(file_path) }
@@ -80,6 +99,39 @@ RSpec.describe Gitlab::Database::Dictionary, feature_category: :database do
expect { database_dictionary.validate! }.to raise_error(Gitlab::Database::GitlabSchema::UnknownSchemaError)
end
end
+
+ context 'with allow_cross_joins' do
+ let(:file_path) { 'db/docs/achievements.yml' }
+
+ describe '#allow_cross_to_schemas' do
+ it 'returns the list of allowed schemas' do
+ expect(database_dictionary.allow_cross_to_schemas(:joins))
+ .to contain_exactly(:gitlab_main_clusterwide)
+ end
+ end
+ end
+
+ context 'with allow_cross_transactions' do
+ let(:file_path) { 'db/docs/activity_pub_releases_subscriptions.yml' }
+
+ describe '#allow_cross_to_schemas' do
+ it 'returns the list of allowed schemas' do
+ expect(database_dictionary.allow_cross_to_schemas(:transactions))
+ .to contain_exactly(:gitlab_main_clusterwide)
+ end
+ end
+ end
+
+ context 'with allow_cross_foreign_keys' do
+ let(:file_path) { 'db/docs/agent_group_authorizations.yml' }
+
+ describe '#allow_cross_to_schemas' do
+ it 'returns the list of allowed schemas' do
+ expect(database_dictionary.allow_cross_to_schemas(:foreign_keys))
+ .to contain_exactly(:gitlab_main_clusterwide)
+ end
+ end
+ end
end
context 'for a view' do