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
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-09 00:09:55 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-09 00:09:55 +0300
commit6869f07304d5bcea12ec61ca6362259f3c72fdf8 (patch)
tree486145ef7341ea60b9c2d6e1e1fa44162e912316 /spec/lib
parent8b0d3151ae81cef695647771d1781c535d6f6cf5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb36
-rw-r--r--spec/lib/gitlab/gitaly_client/commit_service_spec.rb37
2 files changed, 68 insertions, 5 deletions
diff --git a/spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb b/spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb
index e6014f81b74..5b6967c2d14 100644
--- a/spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb
+++ b/spec/lib/gitlab/database/partitioning/sliding_list_strategy_spec.rb
@@ -2,10 +2,15 @@
require 'spec_helper'
-RSpec.describe Gitlab::Database::Partitioning::SlidingListStrategy do
+RSpec.describe Gitlab::Database::Partitioning::SlidingListStrategy, feature_category: :database do
+ include Gitlab::Database::DynamicModelHelpers
+
let(:connection) { ActiveRecord::Base.connection }
- let(:table_name) { :_test_partitioned_test }
- let(:model) { double('model', table_name: table_name, ignored_columns: %w[partition], connection: connection) }
+ let(:table_name) { '_test_partitioned_test' }
+ let(:model) do
+ define_batchable_model(table_name, connection: connection).tap { |m| m.ignored_columns = %w[partition] }
+ end
+
let(:next_partition_if) { double('next_partition_if') }
let(:detach_partition_if) { double('detach_partition_if') }
@@ -87,6 +92,31 @@ RSpec.describe Gitlab::Database::Partitioning::SlidingListStrategy do
strategy.validate_and_fix
end
+
+ context 'when the shared connection is for the wrong database' do
+ it 'does not attempt to fix connections' do
+ skip_if_shared_database(:ci)
+ expect(strategy.model.connection).not_to receive(:change_column_default)
+
+ Ci::ApplicationRecord.connection.execute(<<~SQL)
+ create table #{table_name}
+ (
+ id serial not null,
+ partition bigint not null default 1,
+ created_at timestamptz not null,
+ primary key (id, partition)
+ )
+ partition by list(partition);
+
+ create table #{table_name}_1
+ partition of #{table_name} for values in (1);
+ SQL
+
+ Gitlab::Database::SharedModel.using_connection(Ci::ApplicationRecord.connection) do
+ strategy.validate_and_fix
+ end
+ end
+ end
end
describe '#active_partition' do
diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
index 52652caa7f6..0bdb9f7938d 100644
--- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
@@ -169,10 +169,19 @@ RSpec.describe Gitlab::GitalyClient::CommitService, feature_category: :gitaly do
describe '#find_changed_paths' do
let(:commits) { %w[1a0b36b3cdad1d2ee32457c102a8c0b7056fa863 cfe32cf61b73a0d5e9f13e774abde7ff789b1660] }
+ let(:requests) do
+ [
+ Gitaly::FindChangedPathsRequest::Request.new(
+ commit_request: Gitaly::FindChangedPathsRequest::Request::CommitRequest.new(commit_revision: '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863')
+ ),
+ Gitaly::FindChangedPathsRequest::Request.new(
+ commit_request: Gitaly::FindChangedPathsRequest::Request::CommitRequest.new(commit_revision: 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660')
+ )
+ ]
+ end
it 'sends an RPC request and returns the stats' do
- request = Gitaly::FindChangedPathsRequest.new(repository: repository_message,
- commits: commits)
+ request = Gitaly::FindChangedPathsRequest.new(repository: repository_message, requests: requests)
changed_paths_response = Gitaly::FindChangedPathsResponse.new(
paths: [{
@@ -188,6 +197,30 @@ RSpec.describe Gitlab::GitalyClient::CommitService, feature_category: :gitaly do
expect(returned_value.as_json).to eq(mapped_expected_value.as_json)
end
+
+ context 'when feature flag "find_changed_paths_new_format" is disabled' do
+ before do
+ stub_feature_flags(find_changed_paths_new_format: false)
+ end
+
+ it 'sends an RPC request and returns the stats' do
+ request = Gitaly::FindChangedPathsRequest.new(repository: repository_message, commits: commits)
+
+ changed_paths_response = Gitaly::FindChangedPathsResponse.new(
+ paths: [{
+ path: "app/assets/javascripts/boards/components/project_select.vue",
+ status: :MODIFIED
+ }])
+
+ expect_any_instance_of(Gitaly::DiffService::Stub).to receive(:find_changed_paths)
+ .with(request, kind_of(Hash)).and_return([changed_paths_response])
+
+ returned_value = described_class.new(repository).find_changed_paths(commits)
+ mapped_expected_value = changed_paths_response.paths.map { |path| Gitlab::Git::ChangedPath.new(status: path.status, path: path.path) }
+
+ expect(returned_value.as_json).to eq(mapped_expected_value.as_json)
+ end
+ end
end
describe '#tree_entries' do