diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 18:09:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 18:09:28 +0300 |
commit | 14fb5a922285d71fea67de59164ee4bb81ee3486 (patch) | |
tree | d3f585c54feb676aec2f14cc85fe32d615fd7fc0 /spec/lib/gitlab/database/postgresql_adapter | |
parent | d9b0b3243e3cd71a08ff5d4035b7882cc7a5a35f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/database/postgresql_adapter')
-rw-r--r-- | spec/lib/gitlab/database/postgresql_adapter/dump_schema_versions_mixin_spec.rb | 35 | ||||
-rw-r--r-- | spec/lib/gitlab/database/postgresql_adapter/schema_versions_copy_mixin_spec.rb | 42 |
2 files changed, 35 insertions, 42 deletions
diff --git a/spec/lib/gitlab/database/postgresql_adapter/dump_schema_versions_mixin_spec.rb b/spec/lib/gitlab/database/postgresql_adapter/dump_schema_versions_mixin_spec.rb new file mode 100644 index 00000000000..ca9f4af9187 --- /dev/null +++ b/spec/lib/gitlab/database/postgresql_adapter/dump_schema_versions_mixin_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Database::PostgresqlAdapter::DumpSchemaVersionsMixin do + let(:schema_migration) { double('schema_migration', all_versions: versions) } + + let(:instance) do + Object.new.extend(described_class) + end + + before do + allow(instance).to receive(:schema_migration).and_return(schema_migration) + end + + context 'when version files exist' do + let(:versions) { %w(5 2 1000 200 4 93 2) } + + it 'touches version files' do + expect(Gitlab::Database::SchemaVersionFiles).to receive(:touch_all).with(versions) + + instance.dump_schema_information + end + end + + context 'when version files do not exist' do + let(:versions) { [] } + + it 'does not touch version files' do + expect(Gitlab::Database::SchemaVersionFiles).not_to receive(:touch_all) + + instance.dump_schema_information + end + end +end diff --git a/spec/lib/gitlab/database/postgresql_adapter/schema_versions_copy_mixin_spec.rb b/spec/lib/gitlab/database/postgresql_adapter/schema_versions_copy_mixin_spec.rb deleted file mode 100644 index c6333e4a4dc..00000000000 --- a/spec/lib/gitlab/database/postgresql_adapter/schema_versions_copy_mixin_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::Database::PostgresqlAdapter::SchemaVersionsCopyMixin do - let(:schema_migration) { double('schem_migration', table_name: table_name, all_versions: versions) } - let(:versions) { %w(5 2 1000 200 4 93 2) } - let(:table_name) { "schema_migrations" } - - let(:instance) do - Object.new.extend(described_class) - end - - before do - allow(instance).to receive(:schema_migration).and_return(schema_migration) - allow(instance).to receive(:quote_table_name).with(table_name).and_return("\"#{table_name}\"") - end - - subject { instance.dump_schema_information } - - it 'uses COPY FROM STDIN' do - expect(subject.split("\n").first).to match(/COPY "schema_migrations" \(version\) FROM STDIN;/) - end - - it 'contains a sorted list of versions by their numeric value' do - version_lines = subject.split("\n")[1..-2].map(&:to_i) - - expect(version_lines).to eq(versions.map(&:to_i).sort) - end - - it 'contains a end-of-data marker' do - expect(subject).to end_with("\\.\n") - end - - context 'with non-Integer versions' do - let(:versions) { %w(5 2 4 abc) } - - it 'raises an error' do - expect { subject }.to raise_error(/invalid value for Integer/) - end - end -end |