omnibus 1.3.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -1
- data/.rubocop.yml +30 -0
- data/.travis.yml +14 -3
- data/CHANGELOG.md +72 -49
- data/Gemfile +8 -5
- data/NOTICE +2 -2
- data/README.md +65 -7
- data/Rakefile +12 -3
- data/bin/makeself-header.sh +1 -1
- data/bin/makeself.sh +2 -2
- data/bin/omnibus +2 -2
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +1 -0
- data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +1 -0
- data/functional/fixtures/mac_pkg/package-scripts/functional-test-project/postinstall +4 -0
- data/functional/packagers/mac_pkg_spec.rb +72 -0
- data/lib/omnibus/artifact.rb +11 -13
- data/lib/omnibus/build_version.rb +18 -21
- data/lib/omnibus/builder.rb +37 -48
- data/lib/omnibus/clean_tasks.rb +3 -5
- data/lib/omnibus/cli/application.rb +46 -53
- data/lib/omnibus/cli/base.rb +16 -19
- data/lib/omnibus/cli/build.rb +13 -13
- data/lib/omnibus/cli/cache.rb +13 -15
- data/lib/omnibus/cli/release.rb +4 -9
- data/lib/omnibus/cli.rb +2 -4
- data/lib/omnibus/config.rb +43 -23
- data/lib/omnibus/exceptions.rb +35 -1
- data/lib/omnibus/fetcher.rb +9 -13
- data/lib/omnibus/fetchers/git_fetcher.rb +15 -19
- data/lib/omnibus/fetchers/net_fetcher.rb +34 -38
- data/lib/omnibus/fetchers/path_fetcher.rb +7 -9
- data/lib/omnibus/fetchers/s3_cache_fetcher.rb +3 -4
- data/lib/omnibus/fetchers.rb +3 -3
- data/lib/omnibus/health_check.rb +126 -127
- data/lib/omnibus/library.rb +11 -12
- data/lib/omnibus/overrides.rb +6 -8
- data/lib/omnibus/package_release.rb +20 -22
- data/lib/omnibus/packagers/mac_pkg.rb +285 -0
- data/lib/omnibus/project.rb +215 -110
- data/lib/omnibus/reports.rb +16 -24
- data/lib/omnibus/s3_cacher.rb +15 -21
- data/lib/omnibus/software.rb +178 -88
- data/lib/omnibus/util.rb +25 -13
- data/lib/omnibus/version.rb +2 -2
- data/lib/omnibus.rb +11 -13
- data/omnibus.gemspec +20 -18
- data/spec/artifact_spec.rb +55 -52
- data/spec/build_version_spec.rb +121 -129
- data/spec/config_spec.rb +40 -0
- data/spec/data/projects/chefdk.rb +41 -0
- data/spec/data/projects/sample.rb +10 -0
- data/spec/data/software/erchef.rb +12 -12
- data/spec/data/software/zlib.rb +67 -0
- data/spec/fetchers/git_fetcher_spec.rb +55 -48
- data/spec/fetchers/net_fetcher_spec.rb +72 -78
- data/spec/omnibus_spec.rb +59 -0
- data/spec/overrides_spec.rb +64 -64
- data/spec/package_release_spec.rb +65 -64
- data/spec/packagers/mac_pkg_spec.rb +261 -0
- data/spec/project_spec.rb +138 -0
- data/spec/s3_cacher_spec.rb +9 -10
- data/spec/software_spec.rb +71 -50
- data/spec/spec_helper.rb +14 -7
- metadata +68 -60
- data/.rspec +0 -1
- data/.yardopts +0 -6
- data/spec/software_dirs_spec.rb +0 -34
@@ -1,86 +1,94 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Omnibus::GitFetcher do
|
4
|
-
let(:shell_out)
|
4
|
+
let(:shell_out) do
|
5
5
|
shell_out = double('Mixlib::ShellOut')
|
6
6
|
stub_const('Mixlib::ShellOut', shell_out)
|
7
7
|
shell_out
|
8
|
-
|
9
|
-
let(:software)
|
10
|
-
double('software').tap
|
11
|
-
s.stub :
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
|
16
|
-
|
8
|
+
end
|
9
|
+
let(:software) do
|
10
|
+
double('software').tap do |s|
|
11
|
+
s.stub name: 'project',
|
12
|
+
source: { git: 'git@example.com:test/project.git' },
|
13
|
+
version: '0.0.1',
|
14
|
+
project_dir: '/tmp/project'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
17
18
|
def expect_git_clone_and_ls_remote
|
18
19
|
expect_git_clone
|
19
20
|
expect_git_ls_remote
|
20
21
|
end
|
22
|
+
|
21
23
|
def expect_git_clone
|
22
24
|
double('git_clone').tap do |g|
|
23
|
-
shell_out.
|
24
|
-
.with('git clone git@example.com:test/project.git /tmp/project', :
|
25
|
+
expect(shell_out).to receive(:new)
|
26
|
+
.with('git clone git@example.com:test/project.git /tmp/project', live_stream: STDOUT)
|
25
27
|
.ordered
|
26
28
|
.and_return(g)
|
27
|
-
g.
|
28
|
-
g.
|
29
|
+
expect(g).to receive(:run_command).ordered
|
30
|
+
expect(g).to receive(:error!).ordered
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
31
34
|
def expect_git_ls_remote
|
32
35
|
double('git_ls_remote').tap do |g|
|
33
|
-
shell_out.
|
34
|
-
.with('git ls-remote origin 0.0.1*', :
|
36
|
+
expect(shell_out).to receive(:new)
|
37
|
+
.with('git ls-remote origin 0.0.1*', live_stream: STDOUT, cwd: '/tmp/project')
|
35
38
|
.ordered
|
36
39
|
.and_return(g)
|
37
|
-
g.
|
38
|
-
g.
|
39
|
-
g.stub(:
|
40
|
+
expect(g).to receive(:run_command).ordered
|
41
|
+
expect(g).to receive(:error!).ordered
|
42
|
+
g.stub(stdout: git_ls_remote_out)
|
40
43
|
end
|
41
44
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
|
46
|
+
describe '#fetch' do
|
47
|
+
context 'when the project is not cloned yet' do
|
48
|
+
before do
|
45
49
|
File.stub(:exist?).with('/tmp/project/.git').and_return(false)
|
46
|
-
|
47
|
-
|
48
|
-
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when the source repository is accessible' do
|
53
|
+
subject do
|
49
54
|
Omnibus::GitFetcher.new software
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when the ref exists' do
|
58
|
+
let(:git_ls_remote_out) do
|
53
59
|
'a2ed66c01f42514bcab77fd628149eccb4ecee28 refs/tags/0.0.1'
|
54
|
-
|
60
|
+
end
|
61
|
+
|
55
62
|
it 'should clone the Git repository and then check out the commit' do
|
56
63
|
1.times { expect_git_clone_and_ls_remote }
|
57
64
|
double('git_checkout').tap do |g|
|
58
|
-
shell_out.
|
59
|
-
.with('git checkout a2ed66c01f42514bcab77fd628149eccb4ecee28', :
|
65
|
+
expect(shell_out).to receive(:new)
|
66
|
+
.with('git checkout a2ed66c01f42514bcab77fd628149eccb4ecee28', live_stream: STDOUT, cwd: '/tmp/project')
|
60
67
|
.ordered
|
61
68
|
.and_return(g)
|
62
|
-
g.
|
63
|
-
g.
|
69
|
+
expect(g).to receive(:run_command).ordered
|
70
|
+
expect(g).to receive(:error!).ordered
|
64
71
|
end
|
65
72
|
|
66
73
|
expect { subject.fetch }.to_not raise_error
|
67
74
|
end
|
68
75
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
76
|
+
|
77
|
+
context 'when the ref does not exist' do
|
78
|
+
let(:git_ls_remote_out) { '' }
|
79
|
+
|
73
80
|
it 'should clone the Git repository and then fail while retrying 3 times' do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
subject.
|
81
|
+
4.times do
|
82
|
+
expect_git_clone
|
83
|
+
4.times do
|
84
|
+
expect_git_ls_remote
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
expect_any_instance_of(Omnibus::Fetcher::ErrorReporter).to receive(:explain)
|
89
|
+
.with(%q|Failed to find any commits for the ref '0.0.1'|)
|
90
|
+
expect(subject).to receive(:log).with(/git ls\-remote failed/).at_least(1).times
|
91
|
+
expect(subject).to receive(:log).with(/git clone\/fetch failed/).at_least(1).times
|
84
92
|
# Prevent sleeping to run the spec fast
|
85
93
|
subject.stub(:sleep)
|
86
94
|
expect { subject.fetch }.to raise_error(/Could not parse SHA reference/)
|
@@ -90,4 +98,3 @@ describe Omnibus::GitFetcher do
|
|
90
98
|
end
|
91
99
|
end
|
92
100
|
end
|
93
|
-
|
@@ -1,61 +1,56 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Omnibus::NetFetcher do
|
4
|
-
it
|
4
|
+
it 'should download and uncompress zip files' do
|
5
5
|
software_mock = double('software')
|
6
|
-
software_mock.stub :
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
6
|
+
software_mock.stub project_file: 'file.zip',
|
7
|
+
name: 'file',
|
8
|
+
source: '/tmp/out',
|
9
|
+
checksum: 'abc123',
|
10
|
+
source_uri: 'http://example.com/file.zip',
|
11
|
+
source_dir: '/tmp/out',
|
12
|
+
project_dir: '/tmp/project'
|
13
13
|
net_fetcher = Omnibus::NetFetcher.new software_mock
|
14
|
-
net_fetcher.extract_cmd.
|
14
|
+
expect(net_fetcher.extract_cmd).to eq('unzip file.zip -d /tmp/out')
|
15
15
|
end
|
16
|
-
it
|
16
|
+
it 'should download and uncompress .tar.xz files' do
|
17
17
|
software_mock = double('software')
|
18
|
-
software_mock.stub :
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
18
|
+
software_mock.stub project_file: 'file.tar.xz',
|
19
|
+
name: 'file',
|
20
|
+
source: '/tmp/out',
|
21
|
+
checksum: 'abc123',
|
22
|
+
source_uri: 'http://example.com/file.tar.xz',
|
23
|
+
source_dir: '/tmp/out',
|
24
|
+
project_dir: '/tmp/project'
|
25
25
|
net_fetcher = Omnibus::NetFetcher.new software_mock
|
26
|
-
net_fetcher.extract_cmd.
|
26
|
+
expect(net_fetcher.extract_cmd).to eq('xz -dc file.tar.xz | ( cd /tmp/out && tar -xf - )')
|
27
27
|
end
|
28
|
-
it
|
28
|
+
it 'should download and uncompress .txz files' do
|
29
29
|
software_mock = double('software')
|
30
|
-
software_mock.stub :
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
30
|
+
software_mock.stub project_file: 'file.txz',
|
31
|
+
name: 'file',
|
32
|
+
source: '/tmp/out',
|
33
|
+
checksum: 'abc123',
|
34
|
+
source_uri: 'http://example.com/file.txz',
|
35
|
+
source_dir: '/tmp/out',
|
36
|
+
project_dir: '/tmp/project'
|
37
37
|
net_fetcher = Omnibus::NetFetcher.new software_mock
|
38
|
-
net_fetcher.extract_cmd.
|
38
|
+
expect(net_fetcher.extract_cmd).to eq('xz -dc file.txz | ( cd /tmp/out && tar -xf - )')
|
39
39
|
end
|
40
40
|
|
41
|
-
describe
|
41
|
+
describe 'http_proxy helper' do
|
42
42
|
before(:each) do
|
43
43
|
software_mock = double('software')
|
44
|
-
software_mock.stub
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
44
|
+
software_mock.stub project_file: 'file.txz',
|
45
|
+
name: 'file',
|
46
|
+
source: '/tmp/out',
|
47
|
+
checksum: 'abc123',
|
48
|
+
source_uri: 'http://example.com/file.txz',
|
49
|
+
source_dir: '/tmp/out',
|
50
|
+
project_dir: '/tmp/project'
|
51
51
|
@net_fetcher = Omnibus::NetFetcher.new(software_mock)
|
52
|
-
env_vars =
|
53
|
-
|
54
|
-
'HTTP_PROXY_PASS',
|
55
|
-
'http_proxy',
|
56
|
-
'http_proxy_user',
|
57
|
-
'http_proxy_pass']
|
58
|
-
@orig_env = env_vars.inject({}) do |h, var|
|
52
|
+
env_vars = %w(HTTP_PROXY HTTP_PROXY_USER HTTP_PROXY_PASS http_proxy http_proxy_user http_proxy_pass)
|
53
|
+
@orig_env = env_vars.reduce({}) do |h, var|
|
59
54
|
h[var] = ENV.delete(var)
|
60
55
|
h
|
61
56
|
end
|
@@ -66,60 +61,59 @@ describe Omnibus::NetFetcher do
|
|
66
61
|
@orig_env.each { |var, val| ENV[var] = val }
|
67
62
|
end
|
68
63
|
|
69
|
-
describe
|
70
|
-
it
|
71
|
-
ENV['lower'] =
|
72
|
-
@net_fetcher.get_env('LOWER').
|
73
|
-
@net_fetcher.get_env('lower').
|
64
|
+
describe 'get_env handles upper and lower case env vars' do
|
65
|
+
it 'lower via upper' do
|
66
|
+
ENV['lower'] = 'abc'
|
67
|
+
expect(@net_fetcher.get_env('LOWER')).to eq('abc')
|
68
|
+
expect(@net_fetcher.get_env('lower')).to eq('abc')
|
74
69
|
end
|
75
70
|
|
76
|
-
it
|
77
|
-
ENV['UPPER'] =
|
78
|
-
@net_fetcher.get_env('upper').
|
79
|
-
@net_fetcher.get_env('UPPER').
|
71
|
+
it 'upper via lower' do
|
72
|
+
ENV['UPPER'] = 'abc'
|
73
|
+
expect(@net_fetcher.get_env('upper')).to eq('abc')
|
74
|
+
expect(@net_fetcher.get_env('UPPER')).to eq('abc')
|
80
75
|
end
|
81
76
|
end
|
82
77
|
|
83
|
-
it
|
84
|
-
@net_fetcher.http_proxy.
|
78
|
+
it 'should return nil when no proxy is set in env' do
|
79
|
+
expect(@net_fetcher.http_proxy).to be_nil
|
85
80
|
end
|
86
81
|
|
87
|
-
it
|
88
|
-
ENV['HTTP_PROXY'] =
|
89
|
-
@net_fetcher.http_proxy.
|
82
|
+
it 'should return a URI object when HTTP_PROXY is set' do
|
83
|
+
ENV['HTTP_PROXY'] = 'http://my.proxy'
|
84
|
+
expect(@net_fetcher.http_proxy).to eq(URI.parse('http://my.proxy'))
|
90
85
|
end
|
91
86
|
|
92
|
-
it
|
93
|
-
ENV['HTTP_PROXY'] =
|
94
|
-
ENV['HTTP_PROXY_USER'] =
|
95
|
-
ENV['HTTP_PROXY_PASS'] =
|
96
|
-
@net_fetcher.http_proxy.
|
87
|
+
it 'sets user and pass from env when set' do
|
88
|
+
ENV['HTTP_PROXY'] = 'my.proxy'
|
89
|
+
ENV['HTTP_PROXY_USER'] = 'alex'
|
90
|
+
ENV['HTTP_PROXY_PASS'] = 'sesame'
|
91
|
+
expect(@net_fetcher.http_proxy).to eq(URI.parse('http://alex:sesame@my.proxy'))
|
97
92
|
end
|
98
93
|
|
99
|
-
it
|
100
|
-
ENV['HTTP_PROXY'] =
|
101
|
-
ENV['HTTP_PROXY_USER'] =
|
102
|
-
ENV['HTTP_PROXY_PASS'] =
|
103
|
-
@net_fetcher.http_proxy.
|
94
|
+
it 'uses user and pass in URL before those in env' do
|
95
|
+
ENV['HTTP_PROXY'] = 'sally:peanut@my.proxy'
|
96
|
+
ENV['HTTP_PROXY_USER'] = 'alex'
|
97
|
+
ENV['HTTP_PROXY_PASS'] = 'sesame'
|
98
|
+
expect(@net_fetcher.http_proxy).to eq(URI.parse('http://sally:peanut@my.proxy'))
|
104
99
|
end
|
105
100
|
|
106
101
|
it "proxies if host doesn't match exclude list" do
|
107
|
-
ENV['NO_PROXY'] =
|
108
|
-
a_url = URI.parse(
|
109
|
-
@net_fetcher.excluded_from_proxy?(a_url.host).
|
102
|
+
ENV['NO_PROXY'] = 'google.com,www.buz.org'
|
103
|
+
a_url = URI.parse('http://should.proxy.com/123')
|
104
|
+
expect(@net_fetcher.excluded_from_proxy?(a_url.host)).to be_false
|
110
105
|
|
111
|
-
b_url = URI.parse(
|
112
|
-
@net_fetcher.excluded_from_proxy?(b_url.host).
|
106
|
+
b_url = URI.parse('http://buz.org/123')
|
107
|
+
expect(@net_fetcher.excluded_from_proxy?(b_url.host)).to be_false
|
113
108
|
end
|
114
109
|
|
115
|
-
it
|
116
|
-
ENV['NO_PROXY'] =
|
117
|
-
a_url = URI.parse(
|
118
|
-
@net_fetcher.excluded_from_proxy?(a_url.host).
|
110
|
+
it 'does not proxy if host matches exclude list' do
|
111
|
+
ENV['NO_PROXY'] = 'google.com,www.buz.org'
|
112
|
+
a_url = URI.parse('http://google.com/hello')
|
113
|
+
expect(@net_fetcher.excluded_from_proxy?(a_url.host)).to be_true
|
119
114
|
|
120
|
-
b_url = URI.parse(
|
121
|
-
@net_fetcher.excluded_from_proxy?(b_url.host).
|
115
|
+
b_url = URI.parse('http://www.buz.org/123')
|
116
|
+
expect(@net_fetcher.excluded_from_proxy?(b_url.host)).to be_true
|
122
117
|
end
|
123
118
|
end
|
124
119
|
end
|
125
|
-
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'omnibus'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Omnibus do
|
5
|
+
# evil class variables
|
6
|
+
before :each do
|
7
|
+
Omnibus.class_eval { @omnibus_software_root = nil }
|
8
|
+
Omnibus.class_eval { @software_dirs = nil }
|
9
|
+
end
|
10
|
+
|
11
|
+
after :each do
|
12
|
+
Omnibus.class_eval { @omnibus_software_root = nil }
|
13
|
+
Omnibus.class_eval { @software_dirs = nil }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '::omnibus_software_root' do
|
17
|
+
it 'reads the software_gem out of Omnibus::Config.software_gem' do
|
18
|
+
spec_array = [double(Gem::Specification, gem_dir: '/data')]
|
19
|
+
expect(Omnibus::Config).to receive(:software_gem)
|
20
|
+
.and_return('my-omnibus-software-gem')
|
21
|
+
expect(Gem::Specification).to receive(:find_all_by_name)
|
22
|
+
.with('my-omnibus-software-gem')
|
23
|
+
.and_return(spec_array)
|
24
|
+
|
25
|
+
Omnibus.omnibus_software_root
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'uses the omnibus-software gem as the default' do
|
29
|
+
spec_array = [double(Gem::Specification, gem_dir: '/data')]
|
30
|
+
expect(Gem::Specification).to receive(:find_all_by_name)
|
31
|
+
.with('omnibus-software')
|
32
|
+
.and_return(spec_array)
|
33
|
+
|
34
|
+
Omnibus.omnibus_software_root
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#software_dirs' do
|
39
|
+
context 'omnibus_software_root not nil' do
|
40
|
+
before do
|
41
|
+
Omnibus.stub(:omnibus_software_root) { './data' }
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'will include list of software from omnibus-software gem' do
|
45
|
+
expect(Omnibus.software_dirs.length).to eq(2)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'omnibus_software_root nil' do
|
50
|
+
before do
|
51
|
+
Omnibus.stub(:omnibus_software_root) { nil }
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'will not include list of software from omnibus-software gem' do
|
55
|
+
expect(Omnibus.software_dirs.length).to eq(1)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/overrides_spec.rb
CHANGED
@@ -2,113 +2,113 @@ require 'omnibus/overrides'
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Omnibus::Overrides do
|
5
|
-
describe
|
5
|
+
describe '#parse_file' do
|
6
6
|
|
7
|
-
let(:overrides){Omnibus::Overrides.parse_file(file)}
|
8
|
-
subject{overrides}
|
7
|
+
let(:overrides) { Omnibus::Overrides.parse_file(file) }
|
8
|
+
subject { overrides }
|
9
9
|
|
10
|
-
context
|
11
|
-
let(:file){ overrides_path(
|
10
|
+
context 'with a valid overrides file' do
|
11
|
+
let(:file) { overrides_path('good') }
|
12
12
|
|
13
|
-
its(:size){should eq(5)}
|
14
|
-
its([
|
15
|
-
its([
|
16
|
-
its([
|
17
|
-
its([
|
18
|
-
its([
|
13
|
+
its(:size) { should eq(5) }
|
14
|
+
its(['foo']) { should eq('1.2.3') }
|
15
|
+
its(['bar']) { should eq('0.0.1') }
|
16
|
+
its(['baz']) { should eq('deadbeefdeadbeefdeadbeefdeadbeef') }
|
17
|
+
its(['spunky']) { should eq('master') }
|
18
|
+
its(['monkey']) { should eq('release') }
|
19
19
|
end
|
20
20
|
|
21
|
-
context
|
22
|
-
let(:file){ overrides_path(
|
23
|
-
|
24
|
-
it
|
25
|
-
expect{ overrides }.to raise_error(ArgumentError, "Invalid overrides line: 'THIS IS A BAD LINE'")
|
21
|
+
context 'with an overrides file that contains a bad line' do
|
22
|
+
let(:file) { overrides_path('bad_line') }
|
23
|
+
|
24
|
+
it 'fails' do
|
25
|
+
expect { overrides }.to raise_error(ArgumentError, "Invalid overrides line: 'THIS IS A BAD LINE'")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
context
|
30
|
-
let(:file){ overrides_path(
|
31
|
-
let(:duplicated_package){
|
32
|
-
it
|
33
|
-
expect{ overrides }.to raise_error(ArgumentError, "Multiple overrides present for '#{duplicated_package}' in overrides file #{file}!")
|
29
|
+
context 'with an overrides file that contains duplicates' do
|
30
|
+
let(:file) { overrides_path('with_dupes') }
|
31
|
+
let(:duplicated_package) { 'erchef' }
|
32
|
+
it 'fails' do
|
33
|
+
expect { overrides }.to raise_error(ArgumentError, "Multiple overrides present for '#{duplicated_package}' in overrides file #{file}!")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
context "when passed 'nil'" do
|
38
|
-
let(:file){nil}
|
39
|
-
it{should be_nil}
|
38
|
+
let(:file) { nil }
|
39
|
+
it { should be_nil }
|
40
40
|
end
|
41
|
-
end #parse_file
|
41
|
+
end # parse_file
|
42
42
|
|
43
|
-
describe
|
43
|
+
describe '#resolve_override_file' do
|
44
44
|
before :each do
|
45
45
|
@original = ENV['OMNIBUS_OVERRIDE_FILE']
|
46
46
|
ENV['OMNIBUS_OVERRIDE_FILE'] = env_override_file
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
after :each do
|
50
50
|
ENV['OMNIBUS_OVERRIDE_FILE'] = @original
|
51
51
|
end
|
52
|
-
|
53
|
-
subject{ Omnibus::Overrides.resolve_override_file }
|
54
|
-
|
55
|
-
context
|
56
|
-
let(:env_override_file){nil}
|
52
|
+
|
53
|
+
subject { Omnibus::Overrides.resolve_override_file }
|
54
|
+
|
55
|
+
context 'with no environment variable set' do
|
56
|
+
let(:env_override_file) { nil }
|
57
57
|
|
58
58
|
before :each do
|
59
|
-
stub_const(
|
59
|
+
stub_const('Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME', new_default_file)
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'and a non-existent overrides file' do
|
63
|
+
let(:new_default_file) { '/this/file/totally/does/not/exist.txt' }
|
64
|
+
it { should be_nil }
|
60
65
|
end
|
61
|
-
|
62
|
-
context
|
63
|
-
let(:
|
64
|
-
|
66
|
+
|
67
|
+
context 'with an existing overrides file' do
|
68
|
+
let(:path) { overrides_path('good') }
|
69
|
+
let(:new_default_file) { path }
|
70
|
+
it { should eq(path) }
|
65
71
|
end
|
66
|
-
|
67
|
-
context "with an existing overrides file" do
|
68
|
-
let(:path){overrides_path("good")}
|
69
|
-
let(:new_default_file){ path }
|
70
|
-
it{should eq(path)}
|
71
|
-
end
|
72
72
|
end # no environment variable
|
73
73
|
|
74
|
-
context
|
75
|
-
context
|
76
|
-
let(:path){ overrides_path(
|
77
|
-
let(:env_override_file){ path }
|
78
|
-
it{should eq(path)}
|
74
|
+
context 'with OMNIBUS_OVERRIDE_FILE environment variable set' do
|
75
|
+
context 'to an existing file' do
|
76
|
+
let(:path) { overrides_path('good') }
|
77
|
+
let(:env_override_file) { path }
|
78
|
+
it { should eq(path) }
|
79
79
|
end
|
80
80
|
|
81
|
-
context
|
82
|
-
let(:env_override_file){
|
83
|
-
it{should be_nil}
|
81
|
+
context 'to a non-existent file' do
|
82
|
+
let(:env_override_file) { '/this/file/totally/does/not/exist.txt' }
|
83
|
+
it { should be_nil }
|
84
84
|
end
|
85
85
|
|
86
|
-
context
|
87
|
-
let(:env_override_file){
|
88
|
-
let(:new_default_file){overrides_path(
|
86
|
+
context 'to a non-existent file, but with an existing DEFAULT_OVERRIDE_FILE_NAME file' do
|
87
|
+
let(:env_override_file) { '/this/file/totally/does/not/exist.txt' }
|
88
|
+
let(:new_default_file) { overrides_path('good') }
|
89
89
|
|
90
90
|
it "should still return 'nil', because environment variable has priority" do
|
91
|
-
stub_const(
|
91
|
+
stub_const('Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME', new_default_file)
|
92
|
+
|
93
|
+
expect(File.exist?(Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME)).to be_true
|
94
|
+
expect(ENV['OMNIBUS_OVERRIDE_FILE']).to_not be_nil
|
92
95
|
|
93
|
-
|
94
|
-
ENV['OMNIBUS_OVERRIDE_FILE'].should_not be_nil
|
95
|
-
|
96
|
-
subject.should be_nil
|
96
|
+
expect(subject).to be_nil
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
describe
|
103
|
-
context
|
102
|
+
describe '#overrides' do
|
103
|
+
context 'when an overrides file cannot be found' do
|
104
104
|
before :each do
|
105
105
|
Omnibus::Overrides.stub(:resolve_override_file).and_return(nil)
|
106
106
|
end
|
107
|
-
|
108
|
-
it
|
109
|
-
Omnibus::Overrides.overrides.
|
107
|
+
|
108
|
+
it 'returns an empty hash' do
|
109
|
+
expect(Omnibus::Overrides.overrides).to eq({})
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
end
|