diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/lib/gitlab/git | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/lib/gitlab/git')
-rw-r--r-- | spec/lib/gitlab/git/conflict/resolver_spec.rb | 32 | ||||
-rw-r--r-- | spec/lib/gitlab/git/remote_repository_spec.rb | 41 | ||||
-rw-r--r-- | spec/lib/gitlab/git/repository_spec.rb | 32 |
3 files changed, 38 insertions, 67 deletions
diff --git a/spec/lib/gitlab/git/conflict/resolver_spec.rb b/spec/lib/gitlab/git/conflict/resolver_spec.rb new file mode 100644 index 00000000000..2783e955c33 --- /dev/null +++ b/spec/lib/gitlab/git/conflict/resolver_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Git::Conflict::Resolver do + let(:repository) { instance_double(Gitlab::Git::Repository) } + let(:our_commit_oid) { 'our-commit-oid' } + let(:their_commit_oid) { 'their-commit-oid' } + let(:gitaly_conflicts_client) { instance_double(Gitlab::GitalyClient::ConflictsService) } + + subject(:resolver) { described_class.new(repository, our_commit_oid, their_commit_oid) } + + describe '#conflicts' do + before do + allow(repository).to receive(:gitaly_conflicts_client).and_return(gitaly_conflicts_client) + end + + it 'returns list of conflicts' do + conflicts = [double] + + expect(gitaly_conflicts_client).to receive(:list_conflict_files).and_return(conflicts) + expect(resolver.conflicts).to eq(conflicts) + end + + context 'when GRPC::FailedPrecondition is raised' do + it 'rescues and raises Gitlab::Git::Conflict::Resolver::ConflictSideMissing' do + expect(gitaly_conflicts_client).to receive(:list_conflict_files).and_raise(GRPC::FailedPrecondition) + expect { resolver.conflicts }.to raise_error(Gitlab::Git::Conflict::Resolver::ConflictSideMissing) + end + end + end +end diff --git a/spec/lib/gitlab/git/remote_repository_spec.rb b/spec/lib/gitlab/git/remote_repository_spec.rb index 84c17234ae4..c7bc81573a6 100644 --- a/spec/lib/gitlab/git/remote_repository_spec.rb +++ b/spec/lib/gitlab/git/remote_repository_spec.rb @@ -58,45 +58,4 @@ RSpec.describe Gitlab::Git::RemoteRepository, :seed_helper do it { expect(subject.same_repository?(other_repository)).to eq(result) } end end - - describe '#fetch_env' do - let(:remote_repository) { described_class.new(repository) } - - let(:gitaly_client) { double(:gitaly_client) } - let(:address) { 'fake-address' } - let(:token) { 'fake-token' } - - subject { remote_repository.fetch_env } - - before do - allow(remote_repository).to receive(:gitaly_client).and_return(gitaly_client) - - expect(gitaly_client).to receive(:address).with(repository.storage).and_return(address) - expect(gitaly_client).to receive(:token).with(repository.storage).and_return(token) - end - - it { expect(subject).to be_a(Hash) } - it { expect(subject['GITALY_ADDRESS']).to eq(address) } - it { expect(subject['GITALY_TOKEN']).to eq(token) } - it { expect(subject['GITALY_WD']).to eq(Dir.pwd) } - - it 'creates a plausible GIT_SSH_COMMAND' do - git_ssh_command = subject['GIT_SSH_COMMAND'] - - expect(git_ssh_command).to start_with('/') - expect(git_ssh_command).to end_with('/gitaly-ssh upload-pack') - end - - it 'creates a plausible GITALY_PAYLOAD' do - req = Gitaly::SSHUploadPackRequest.decode_json(subject['GITALY_PAYLOAD']) - - expect(remote_repository.gitaly_repository).to eq(req.repository) - end - - context 'when the token is blank' do - let(:token) { '' } - - it { expect(subject.keys).not_to include('GITALY_TOKEN') } - end - end end diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 1ddbdda12b5..336bf20d59c 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -133,32 +133,10 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do expect(metadata['ArchivePrefix']).to eq(expected_prefix) end - context 'when :include_lfs_blobs_in_archive feature flag is disabled' do - let(:expected_path) { File.join(storage_path, cache_key, expected_filename) } + it 'sets ArchivePath to the expected globally-unique path' do + expect(expected_path).to include(File.join(repository.gl_repository, SeedRepo::LastCommit::ID)) - before do - stub_feature_flags(include_lfs_blobs_in_archive: false) - end - - it 'sets ArchivePath to the expected globally-unique path' do - # This is really important from a security perspective. Think carefully - # before changing it: https://gitlab.com/gitlab-org/gitlab-foss/issues/45689 - expect(expected_path).to include(File.join(repository.gl_repository, SeedRepo::LastCommit::ID)) - - expect(metadata['ArchivePath']).to eq(expected_path) - end - end - - context 'when :include_lfs_blobs_in_archive feature flag is enabled' do - before do - stub_feature_flags(include_lfs_blobs_in_archive: true) - end - - it 'sets ArchivePath to the expected globally-unique path' do - expect(expected_path).to include(File.join(repository.gl_repository, SeedRepo::LastCommit::ID)) - - expect(metadata['ArchivePath']).to eq(expected_path) - end + expect(metadata['ArchivePath']).to eq(expected_path) end context 'path is set' do @@ -521,7 +499,9 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do no_tags: true, timeout: described_class::GITLAB_PROJECTS_TIMEOUT, prune: false, - check_tags_changed: false + check_tags_changed: false, + url: nil, + refmap: nil } expect(repository.gitaly_repository_client).to receive(:fetch_remote).with('remote-name', expected_opts) |