blob: d6df2f407aff1fed9d1589ed8a8fc60e5d3c9a76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
require 'spec_helper'
require_relative '../../../lib/gitaly_server/rugged_interceptor.rb'
describe GitalyServer::RuggedInterceptor do
include TestRepo
let(:meth) { GitalyServer::OperationsService.instance_method(:user_create_branch) }
let(:call) { double(metadata: {}) }
subject do
described_class.new.server_streamer(call: call, method: meth) {}
end
context 'no Rugged repositories initialized' do
it 'does not clean up any repositories' do
expect(Rugged::Repository).not_to receive(:new)
subject
end
end
context 'Rugged repository initialized' do
let(:rugged) { rugged_from_gitaly(test_repo_read_only) }
let(:streamer) do
described_class.new.server_streamer(call: call, method: meth) do
Thread.current[Gitlab::Git::Repository::RUGGED_KEY] = [rugged]
end
end
it 'cleans up repositories' do
expect(rugged).to receive(:close).and_call_original
streamer
end
end
end
|