blob: 7252f7d6afb06f6cdd6ce0e9e531e68c53bf9b75 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::GitalyClient::StorageSettings, feature_category: :gitaly do
describe "#initialize" do
context 'when the storage contains no path' do
it 'raises an error' do
expect do
described_class.new("foo" => {})
end.to raise_error(described_class::InvalidConfigurationError)
end
end
context "when the argument isn't a hash" do
it 'raises an error' do
expect do
described_class.new("test")
end.to raise_error("expected a Hash, got a String")
end
end
context 'when the storage is valid' do
it 'raises no error' do
expect do
described_class.new("path" => Rails.root)
end.not_to raise_error
end
end
end
describe '.gitaly_address' do
context 'when the storage settings have no gitaly address but one is requested' do
it 'raises an error' do
expect do
described_class.new("path" => Rails.root).gitaly_address
end.to raise_error("key not found: \"gitaly_address\"")
end
end
context 'when the storage settings have a gitaly address and one is requested' do
it 'returns the setting value' do
expect(described_class.new("path" => Rails.root, "gitaly_address" => "test").gitaly_address).to eq("test")
end
end
context 'when the storage settings have a gitaly address keyed symbolically' do
it 'raises no error' do
expect do
described_class.new("path" => Rails.root, :gitaly_address => "test").gitaly_address
end.not_to raise_error
end
end
context 'when the storage settings have a gitaly address keyed with a string' do
it 'raises no error' do
expect do
described_class.new("path" => Rails.root, "gitaly_address" => "test").gitaly_address
end.not_to raise_error
end
end
end
describe '.disk_access_denied?' do
subject { described_class.disk_access_denied? }
it { is_expected.to be_truthy }
context 'in case of an exception' do
before do
allow(described_class).to receive(:temporarily_allowed?).and_raise('boom')
end
it { is_expected.to be_falsey }
end
end
end
|