minimart 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.travis.yml +13 -0
- data/Gemfile +3 -0
- data/README.md +198 -0
- data/Rakefile +45 -0
- data/bin/minimart +4 -0
- data/lib/minimart.rb +15 -0
- data/lib/minimart/cli.rb +93 -0
- data/lib/minimart/commands/mirror.rb +30 -0
- data/lib/minimart/commands/web.rb +91 -0
- data/lib/minimart/configuration.rb +46 -0
- data/lib/minimart/cookbook.rb +173 -0
- data/lib/minimart/download/cookbook.rb +70 -0
- data/lib/minimart/download/git_cache.rb +60 -0
- data/lib/minimart/download/git_repository.rb +41 -0
- data/lib/minimart/error.rb +32 -0
- data/lib/minimart/inventory_requirement/base_requirement.rb +81 -0
- data/lib/minimart/inventory_requirement/git_requirement.rb +87 -0
- data/lib/minimart/inventory_requirement/git_requirements_builder.rb +101 -0
- data/lib/minimart/inventory_requirement/local_path_requirement.rb +45 -0
- data/lib/minimart/inventory_requirement/local_requirements_builder.rb +31 -0
- data/lib/minimart/inventory_requirement/supermarket_requirements_builder.rb +35 -0
- data/lib/minimart/mirror.rb +12 -0
- data/lib/minimart/mirror/dependency_graph.rb +73 -0
- data/lib/minimart/mirror/download_metadata.rb +57 -0
- data/lib/minimart/mirror/inventory_builder.rb +143 -0
- data/lib/minimart/mirror/inventory_configuration.rb +74 -0
- data/lib/minimart/mirror/inventory_requirements.rb +104 -0
- data/lib/minimart/mirror/local_store.rb +107 -0
- data/lib/minimart/mirror/source.rb +57 -0
- data/lib/minimart/mirror/source_cookbook.rb +77 -0
- data/lib/minimart/mirror/sources.rb +37 -0
- data/lib/minimart/output.rb +34 -0
- data/lib/minimart/utils/archive.rb +39 -0
- data/lib/minimart/utils/file_helper.rb +34 -0
- data/lib/minimart/utils/http.rb +60 -0
- data/lib/minimart/version.rb +3 -0
- data/lib/minimart/web.rb +10 -0
- data/lib/minimart/web/cookbook_show_page_generator.rb +78 -0
- data/lib/minimart/web/cookbooks.rb +83 -0
- data/lib/minimart/web/dashboard_generator.rb +46 -0
- data/lib/minimart/web/html_generator.rb +52 -0
- data/lib/minimart/web/markdown_parser.rb +47 -0
- data/lib/minimart/web/template_helper.rb +132 -0
- data/lib/minimart/web/universe_generator.rb +109 -0
- data/minimart.gemspec +36 -0
- data/spec/fixtures/sample_cookbook.tar.gz +0 -0
- data/spec/fixtures/sample_cookbook/Berksfile +3 -0
- data/spec/fixtures/sample_cookbook/CHANGELOG.md +3 -0
- data/spec/fixtures/sample_cookbook/Gemfile +16 -0
- data/spec/fixtures/sample_cookbook/LICENSE +3 -0
- data/spec/fixtures/sample_cookbook/README.md +42 -0
- data/spec/fixtures/sample_cookbook/Thorfile +5 -0
- data/spec/fixtures/sample_cookbook/Vagrantfile +90 -0
- data/spec/fixtures/sample_cookbook/chefignore +94 -0
- data/spec/fixtures/sample_cookbook/metadata.rb +9 -0
- data/spec/fixtures/sample_cookbook/recipes/default.rb +8 -0
- data/spec/fixtures/sample_inventory.yml +16 -0
- data/spec/fixtures/simple_git_inventory.yml +8 -0
- data/spec/fixtures/simple_inventory.yml +6 -0
- data/spec/fixtures/simple_local_path_inventory.yml +5 -0
- data/spec/fixtures/universe.json +42 -0
- data/spec/fixtures/vcr_cassettes/local_path_cookbooks.yml +3316 -0
- data/spec/fixtures/vcr_cassettes/location_specific_cookbooks.yml +3316 -0
- data/spec/fixtures/vcr_cassettes/supermarket_cookbooks_graph.yml +905 -0
- data/spec/fixtures/vcr_cassettes/supermarket_cookbooks_installing_cookbooks.yml +4218 -0
- data/spec/lib/minimart/cli_spec.rb +104 -0
- data/spec/lib/minimart/commands/mirror_spec.rb +37 -0
- data/spec/lib/minimart/commands/web_spec.rb +75 -0
- data/spec/lib/minimart/configuration_spec.rb +54 -0
- data/spec/lib/minimart/cookbook_spec.rb +137 -0
- data/spec/lib/minimart/download/cookbook_spec.rb +135 -0
- data/spec/lib/minimart/download/git_cache_spec.rb +69 -0
- data/spec/lib/minimart/download/git_repository_spec.rb +39 -0
- data/spec/lib/minimart/error_spec.rb +18 -0
- data/spec/lib/minimart/inventory_requirement/base_requirement_spec.rb +38 -0
- data/spec/lib/minimart/inventory_requirement/git_requirement_spec.rb +92 -0
- data/spec/lib/minimart/inventory_requirement/git_requirements_builder_spec.rb +130 -0
- data/spec/lib/minimart/inventory_requirement/local_path_requirement_spec.rb +35 -0
- data/spec/lib/minimart/inventory_requirement/local_requirements_builder_spec.rb +33 -0
- data/spec/lib/minimart/inventory_requirement/supermarket_requirements_builder_spec.rb +69 -0
- data/spec/lib/minimart/mirror/dependency_graph_spec.rb +123 -0
- data/spec/lib/minimart/mirror/download_metadata_spec.rb +73 -0
- data/spec/lib/minimart/mirror/inventory_builder_spec.rb +195 -0
- data/spec/lib/minimart/mirror/inventory_configuration_spec.rb +86 -0
- data/spec/lib/minimart/mirror/inventory_requirements_spec.rb +78 -0
- data/spec/lib/minimart/mirror/local_store_spec.rb +64 -0
- data/spec/lib/minimart/mirror/source_spec.rb +54 -0
- data/spec/lib/minimart/mirror/sources_spec.rb +50 -0
- data/spec/lib/minimart/output_spec.rb +29 -0
- data/spec/lib/minimart/utils/archive_spec.rb +38 -0
- data/spec/lib/minimart/utils/file_helper_spec.rb +43 -0
- data/spec/lib/minimart/utils/http_spec.rb +37 -0
- data/spec/lib/minimart/web/cookbook_show_page_generator_spec.rb +101 -0
- data/spec/lib/minimart/web/cookbooks_spec.rb +70 -0
- data/spec/lib/minimart/web/dashboard_generator_spec.rb +33 -0
- data/spec/lib/minimart/web/html_generator_spec.rb +34 -0
- data/spec/lib/minimart/web/markdown_parser_spec.rb +54 -0
- data/spec/lib/minimart/web/template_helper_spec.rb +86 -0
- data/spec/lib/minimart/web/universe_generator_spec.rb +125 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/support/file_system.rb +22 -0
- data/web/_assets/javascripts/app.js +164 -0
- data/web/_assets/javascripts/backbone.min.js +6 -0
- data/web/_assets/javascripts/jquery.min.js +4 -0
- data/web/_assets/javascripts/jquery.tabslet.min.js +9 -0
- data/web/_assets/javascripts/manifest.js +5 -0
- data/web/_assets/javascripts/underscore.min.js +5 -0
- data/web/_assets/stylesheets/font-awesome.min.css +4 -0
- data/web/_assets/stylesheets/font-mfizz.css +318 -0
- data/web/_assets/stylesheets/main.css +720 -0
- data/web/_assets/stylesheets/manifest.css +4 -0
- data/web/_assets/stylesheets/normalize.css +427 -0
- data/web/assets/fonts/FontAwesome.otf +0 -0
- data/web/assets/fonts/font-mfizz.eot +0 -0
- data/web/assets/fonts/font-mfizz.svg +1344 -0
- data/web/assets/fonts/font-mfizz.ttf +0 -0
- data/web/assets/fonts/font-mfizz.woff +0 -0
- data/web/assets/fonts/fontawesome-webfont.eot +0 -0
- data/web/assets/fonts/fontawesome-webfont.svg +520 -0
- data/web/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/web/assets/fonts/fontawesome-webfont.woff +0 -0
- data/web/assets/images/header-slim.jpg +0 -0
- data/web/assets/images/icon-search.png +0 -0
- data/web/assets/images/mad-glory-logo.png +0 -0
- data/web/assets/images/main-gradient.png +0 -0
- data/web/assets/images/top-bar-logo.png +0 -0
- data/web/assets/javascripts/application.min.js +5 -0
- data/web/assets/stylesheets/application.min.css +4 -0
- data/web/templates/cookbook_show.erb +96 -0
- data/web/templates/dashboard.erb +81 -0
- data/web/templates/layout.erb +38 -0
- metadata +433 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Download::GitCache do
|
4
|
+
|
5
|
+
describe '#get_repository' do
|
6
|
+
let(:stubbed_repo) { double('git_repository') }
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
allow(Git).to receive(:clone).and_return(stubbed_repo)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should return the repo' do
|
13
|
+
expect(subject.get_repository('git-url')).to eq stubbed_repo
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should download a bare version of the git repo' do
|
17
|
+
expect(Git).to receive(:clone).with('git-url', instance_of(String), bare: true)
|
18
|
+
subject.get_repository('git-url')
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when the repo has already been downloaded' do
|
22
|
+
before(:each) do
|
23
|
+
subject.get_repository('git-url')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should return the repo' do
|
27
|
+
expect(subject.get_repository('git-url')).to eq stubbed_repo
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should not download the repo a second time' do
|
31
|
+
expect(Git).to_not receive(:clone)
|
32
|
+
subject.get_repository('git-url')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#local_path_for' do
|
38
|
+
let(:stubbed_repo) { double('git_repository', repo: double('repo', path: '/path')) }
|
39
|
+
|
40
|
+
before(:each) do
|
41
|
+
allow(subject).to receive(:get_repository).and_return stubbed_repo
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should return the path' do
|
45
|
+
expect(subject.local_path_for('repo')).to eq '/path'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#clear' do
|
50
|
+
let(:path) { Dir.mktmpdir }
|
51
|
+
let(:repo) { double('base', repo: double('repo', 'path' => path)) }
|
52
|
+
|
53
|
+
before(:each) do
|
54
|
+
allow(Git).to receive(:clone).and_return(repo)
|
55
|
+
subject.get_repository('git-url')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should remove empty the cache' do
|
59
|
+
subject.clear
|
60
|
+
expect(subject.has_location?('git-url')).to eq false
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should actually remove any tmp directories' do
|
64
|
+
subject.clear
|
65
|
+
expect(Dir.exists?(path)).to eq false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Download::GitRepository do
|
4
|
+
|
5
|
+
let(:location) { 'http://github.com' }
|
6
|
+
|
7
|
+
subject do
|
8
|
+
Minimart::Download::GitRepository.new(location)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#fetch' do
|
12
|
+
let(:repo) do
|
13
|
+
instance_double('Git::Base',
|
14
|
+
fetch: true,
|
15
|
+
reset_hard: true,
|
16
|
+
revparse: 'master')
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:path) { '/git_path' }
|
20
|
+
|
21
|
+
before(:each) do
|
22
|
+
allow_any_instance_of(Minimart::Download::GitCache).to receive(:get_repository).with(location).and_return repo
|
23
|
+
allow_any_instance_of(Minimart::Download::GitCache).to receive(:local_path_for).with(location).and_return path
|
24
|
+
allow(Git).to receive(:clone).with(path, an_instance_of(String)).and_return repo
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should clone the repo' do
|
28
|
+
expect(repo).to receive(:reset_hard).with('master')
|
29
|
+
subject.fetch('master')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should yield the directory the repo was cloned to' do
|
33
|
+
expect { |b|
|
34
|
+
subject.fetch('master', &b)
|
35
|
+
}.to yield_with_args(an_instance_of(String))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::Error do
|
4
|
+
describe '::handle_exception' do
|
5
|
+
let(:ex) { StandardError.new('test error msg') }
|
6
|
+
|
7
|
+
it 'should print the error' do
|
8
|
+
begin; subject.handle_exception(ex); rescue SystemExit; end
|
9
|
+
expect(Minimart::Configuration.output.io.string).to include 'test error msg'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should exit with a failure status code' do
|
13
|
+
expect {
|
14
|
+
subject.handle_exception(ex)
|
15
|
+
}.to raise_error SystemExit
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::InventoryRequirement::BaseRequirement do
|
4
|
+
|
5
|
+
subject do
|
6
|
+
Minimart::InventoryRequirement::BaseRequirement.new(
|
7
|
+
'mysql',
|
8
|
+
version_requirement: '> 1.0.0')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '::new' do
|
12
|
+
it 'should set the name' do
|
13
|
+
expect(subject.name).to eq 'mysql'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should set the version requirement' do
|
17
|
+
expect(subject.version_requirement).to eq '> 1.0.0'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#explicit_location?' do
|
22
|
+
it 'should return false' do
|
23
|
+
expect(subject.explicit_location?).to eq false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#requirements' do
|
28
|
+
it 'should return the proper requirements' do
|
29
|
+
expect(subject.requirements).to eq 'mysql' => '> 1.0.0'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#matching_source?' do
|
34
|
+
it 'should default to true' do
|
35
|
+
expect(subject.matching_source?({})).to eq true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'minimart/inventory_requirement/base_requirement'
|
3
|
+
require 'minimart/inventory_requirement/git_requirement'
|
4
|
+
|
5
|
+
describe Minimart::InventoryRequirement::GitRequirement do
|
6
|
+
|
7
|
+
let(:requirement) do
|
8
|
+
Minimart::InventoryRequirement::GitRequirement.new(
|
9
|
+
'sample_cookbook',
|
10
|
+
branch: 'new-feature-branch')
|
11
|
+
end
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
allow_any_instance_of(Minimart::Download::GitRepository).to receive(:fetch).
|
15
|
+
with('new-feature-branch').
|
16
|
+
and_yield('spec/fixtures/sample_cookbook')
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '::new' do
|
20
|
+
it 'should set the name' do
|
21
|
+
expect(requirement.name).to eq 'sample_cookbook'
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when a branch is provided' do
|
25
|
+
it 'should set the branch' do
|
26
|
+
expect(requirement.branch).to eq 'new-feature-branch'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when a ref is provided' do
|
31
|
+
it 'should set the sha' do
|
32
|
+
cookbook = Minimart::InventoryRequirement::GitRequirement.new('sample_cookbook', ref: 'SHA')
|
33
|
+
expect(cookbook.ref).to eq 'SHA'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when a tag is provided' do
|
38
|
+
it 'should set the tag' do
|
39
|
+
cookbook = Minimart::InventoryRequirement::GitRequirement.new('sample_cookbook', tag: 'v1.0.0')
|
40
|
+
expect(cookbook.tag).to eq 'v1.0.0'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#explicit_location?' do
|
46
|
+
subject { requirement.explicit_location? }
|
47
|
+
it { is_expected.to eq true }
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#requirements' do
|
51
|
+
before(:each) { requirement.fetch_cookbook }
|
52
|
+
subject { requirement.requirements }
|
53
|
+
it { is_expected.to eq('yum' => '> 3.0.0') }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#matching_source?' do
|
57
|
+
let(:metadata) do
|
58
|
+
{ 'source_type' => 'git', 'commitish_type' => 'branch', 'commitish' => 'new-feature-branch'}
|
59
|
+
end
|
60
|
+
|
61
|
+
subject { requirement.matching_source?(metadata) }
|
62
|
+
|
63
|
+
it { is_expected.to eq true }
|
64
|
+
|
65
|
+
describe 'when the source type is not matching' do
|
66
|
+
before(:each) { metadata['source_type'] = 'local_path' }
|
67
|
+
|
68
|
+
it { is_expected.to eq false }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'when the commitish type is not matching' do
|
72
|
+
before(:each) { metadata['commitish_type'] = 'tag' }
|
73
|
+
|
74
|
+
it { is_expected.to eq false }
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'when the commitish is not matching' do
|
78
|
+
before(:each) { metadata['commitish'] = 'another-branch' }
|
79
|
+
|
80
|
+
it { is_expected.to eq false }
|
81
|
+
|
82
|
+
context 'when the commitish type is a ref' do
|
83
|
+
before(:each) do
|
84
|
+
allow(requirement).to receive('commitish_type').and_return 'ref'
|
85
|
+
metadata['commitish_type'] = 'ref'
|
86
|
+
end
|
87
|
+
|
88
|
+
it { is_expected.to eq true }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::InventoryRequirement::GitRequirementsBuilder do
|
4
|
+
|
5
|
+
let(:raw_requirements) do
|
6
|
+
{
|
7
|
+
'git' => {
|
8
|
+
'location' => 'https://github.com/mysql',
|
9
|
+
'branches' => %w[branch-one branch-two],
|
10
|
+
'tags' => %w[tag-one tag-two],
|
11
|
+
'refs' => %w[ref-one ref-two],
|
12
|
+
}
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
subject do
|
17
|
+
Minimart::InventoryRequirement::GitRequirementsBuilder.new('mysql', raw_requirements)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '::new' do
|
21
|
+
context 'when a location is not provided' do
|
22
|
+
before(:each) { raw_requirements['git'].delete('location') }
|
23
|
+
|
24
|
+
it 'should raise an exception' do
|
25
|
+
expect {
|
26
|
+
subject
|
27
|
+
}.to raise_error Minimart::Error::InvalidInventoryError,
|
28
|
+
%{'mysql' specifies Git requirements, but does not have a location.}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when no commitish is specified' do
|
33
|
+
let(:raw_requirements) do
|
34
|
+
{ 'git' => {'location' => '/'} }
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should raise an exception' do
|
38
|
+
expect {
|
39
|
+
subject
|
40
|
+
}.to raise_error Minimart::Error::InvalidInventoryError,
|
41
|
+
%{'mysql' specified Git requirements, but does not provide a branch|tag|ref}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#build' do
|
47
|
+
it 'should build a requirement for each branch' do
|
48
|
+
raw_requirements['git']['branches'].each do |branch|
|
49
|
+
expect(subject.build.any? { |r| r.branch == branch }).to eq true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should build a requirement for each tag' do
|
54
|
+
raw_requirements['git']['tags'].each do |tag|
|
55
|
+
expect(subject.build.any? { |r| r.tag == tag }).to eq true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should build a requirement for each ref' do
|
60
|
+
raw_requirements['git']['refs'].each do |ref|
|
61
|
+
expect(subject.build.any? { |r| r.ref == ref }).to eq true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should pass the location' do
|
66
|
+
expect(subject.build.all? { |r| r.location == 'https://github.com/mysql' }).to eq true
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when branches is passed a string' do
|
70
|
+
before(:each) { raw_requirements['git'] = { 'location' => '/', 'branches' => 'master' } }
|
71
|
+
|
72
|
+
it 'should still build the proper requirement' do
|
73
|
+
expect(subject.build.first.branch).to eq 'master'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when the string "branch" is used as the key' do
|
78
|
+
before(:each) { raw_requirements['git'] = { 'location' => '/', 'branch' => 'master' } }
|
79
|
+
|
80
|
+
it 'should still build the proper requirement' do
|
81
|
+
expect(subject.build.first.branch).to eq 'master'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when tags is passed a string' do
|
86
|
+
before(:each) do
|
87
|
+
raw_requirements['git'] = { 'location' => '/', 'tags' => 'v0.0.0' }
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should still build the proper requirement' do
|
91
|
+
expect(subject.build.first.tag).to eq 'v0.0.0'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'when the string "tag" is used as the key' do
|
96
|
+
before(:each) { raw_requirements['git'] = { 'location' => '/', 'tag' => 'v0.0.0' } }
|
97
|
+
|
98
|
+
it 'should still build the proper requirement' do
|
99
|
+
expect(subject.build.first.tag).to eq 'v0.0.0'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when refs is passed a string' do
|
104
|
+
before(:each) { raw_requirements['git'] = { 'location' => '/', 'refs' => 'SHA' } }
|
105
|
+
|
106
|
+
it 'should still build the proper requirement' do
|
107
|
+
expect(subject.build.first.ref).to eq 'SHA'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'when the string "ref" is used as the key' do
|
112
|
+
before(:each) { raw_requirements['git'] = { 'location' => '/', 'ref' => 'SHA' } }
|
113
|
+
|
114
|
+
it 'should still build the proper requirement' do
|
115
|
+
expect(subject.build.first.ref).to eq 'SHA'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context 'when there are no git requirements' do
|
120
|
+
subject do
|
121
|
+
Minimart::InventoryRequirement::GitRequirementsBuilder.new('mysql', {})
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should return an empty array' do
|
125
|
+
expect(subject.build.empty?).to eq true
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::InventoryRequirement::LocalPathRequirement do
|
4
|
+
|
5
|
+
let(:requirement) do
|
6
|
+
Minimart::InventoryRequirement::LocalPathRequirement.new('sample_cookbook',
|
7
|
+
path: 'spec/fixtures/sample_cookbook')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '::new' do
|
11
|
+
it 'should set the name' do
|
12
|
+
expect(requirement.name).to eq 'sample_cookbook'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should set the path' do
|
16
|
+
expect(requirement.path).to eq 'spec/fixtures/sample_cookbook'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#explicit_location?' do
|
21
|
+
subject { requirement.explicit_location? }
|
22
|
+
it { is_expected.to eq true }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#matching_source?' do
|
26
|
+
let(:metadata) { { 'source_type' => 'local_path' } }
|
27
|
+
subject { requirement.matching_source?(metadata) }
|
28
|
+
it { is_expected.to eq true }
|
29
|
+
|
30
|
+
context 'when the source type is not local path' do
|
31
|
+
before(:each) { metadata['source_type'] = 'git' }
|
32
|
+
it { is_expected.to eq false }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Minimart::InventoryRequirement::LocalRequirementsBuilder do
|
4
|
+
|
5
|
+
describe '#build' do
|
6
|
+
subject do
|
7
|
+
Minimart::InventoryRequirement::LocalRequirementsBuilder.new('mysql', 'path' => '/my/local/path')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should return a single requirement' do
|
11
|
+
expect(subject.build.size).to eq 1
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should give the requirement the proper name' do
|
15
|
+
expect(subject.build.first.name).to eq 'mysql'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should give the requirement the proper path' do
|
19
|
+
expect(subject.build.first.path).to eq '/my/local/path'
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when no path is provided' do
|
23
|
+
subject do
|
24
|
+
Minimart::InventoryRequirement::LocalRequirementsBuilder.new('mysql', {})
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should return empty' do
|
28
|
+
expect(subject.build).to be_empty
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|