2019-11-12 22:06:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-20 18:33:56 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::GitalyClient::Util do
|
2017-09-20 18:33:56 -04:00
|
|
|
describe '.repository' do
|
|
|
|
let(:repository_storage) { 'default' }
|
|
|
|
let(:relative_path) { 'my/repo.git' }
|
|
|
|
let(:gl_repository) { 'project-1' }
|
|
|
|
let(:git_object_directory) { '.git/objects' }
|
2017-10-05 10:51:31 -04:00
|
|
|
let(:git_alternate_object_directory) { ['/dir/one', '/dir/two'] }
|
2019-01-24 14:37:26 -05:00
|
|
|
let(:gl_project_path) { 'namespace/myproject' }
|
2018-03-30 05:19:46 -04:00
|
|
|
let(:git_env) do
|
|
|
|
{
|
|
|
|
'GIT_OBJECT_DIRECTORY_RELATIVE' => git_object_directory,
|
|
|
|
'GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE' => git_alternate_object_directory
|
|
|
|
}
|
|
|
|
end
|
2017-09-20 18:33:56 -04:00
|
|
|
|
|
|
|
subject do
|
2019-01-24 14:37:26 -05:00
|
|
|
described_class.repository(repository_storage, relative_path, gl_repository, gl_project_path)
|
2017-09-20 18:33:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a Gitaly::Repository with the given data' do
|
2018-03-30 05:19:46 -04:00
|
|
|
allow(Gitlab::Git::HookEnv).to receive(:all).with(gl_repository).and_return(git_env)
|
2017-09-20 18:33:56 -04:00
|
|
|
|
|
|
|
expect(subject).to be_a(Gitaly::Repository)
|
|
|
|
expect(subject.storage_name).to eq(repository_storage)
|
|
|
|
expect(subject.relative_path).to eq(relative_path)
|
|
|
|
expect(subject.gl_repository).to eq(gl_repository)
|
|
|
|
expect(subject.git_object_directory).to eq(git_object_directory)
|
2017-10-05 10:51:31 -04:00
|
|
|
expect(subject.git_alternate_object_directories).to eq(git_alternate_object_directory)
|
2019-01-24 14:37:26 -05:00
|
|
|
expect(subject.gl_project_path).to eq(gl_project_path)
|
2017-09-20 18:33:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|