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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.1 KiB
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Database::SchemaCleaner do
2020-04-22 19:07:51 +05:30
let(:example_schema) { fixture_file(File.join('gitlab', 'database', 'structure_example.sql')) }
let(:io) { StringIO.new }
subject do
described_class.new(example_schema).clean(io)
io.string
end
it 'removes comments on extensions' do
expect(subject).not_to include('COMMENT ON EXTENSION')
end
2020-11-24 15:15:51 +05:30
it 'no assumption about public being the default schema' do
expect(subject).not_to match(/public\.\w+/)
2020-04-22 19:07:51 +05:30
end
2023-03-04 22:38:38 +05:30
it 'cleans up all the gitlab_schema_prevent_write table triggers' do
expect(subject).not_to match(/CREATE TRIGGER gitlab_schema_write_trigger_for_\w+/)
expect(subject).not_to match(/FOR EACH STATEMENT EXECUTE FUNCTION gitlab_schema_prevent_write/)
end
it 'keeps the lock_writes trigger functions' do
expect(subject).to match(/CREATE FUNCTION gitlab_schema_prevent_write/)
end
2020-04-22 19:07:51 +05:30
it 'cleans up the full schema as expected (blackbox test with example)' do
expected_schema = fixture_file(File.join('gitlab', 'database', 'structure_example_cleaned.sql'))
expect(subject).to eq(expected_schema)
end
end