cookbook-omnifetch 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/cookbook-omnifetch.rb +2 -2
- data/lib/cookbook-omnifetch/metadata_based_installer.rb +1 -1
- data/lib/cookbook-omnifetch/version.rb +1 -1
- metadata +15 -57
- data/.gitignore +0 -23
- data/.rspec +0 -1
- data/.travis.yml +0 -11
- data/Gemfile +0 -8
- data/README.md +0 -90
- data/Rakefile +0 -19
- data/cookbook-omnifetch.gemspec +0 -39
- data/spec/fixtures/cookbooks/example_cookbook-0.5.0/README.md +0 -12
- data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +0 -3
- data/spec/fixtures/cookbooks/example_cookbook-0.5.0/recipes/default.rb +0 -8
- data/spec/fixtures/cookbooks/example_cookbook/.gitignore +0 -2
- data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +0 -26
- data/spec/fixtures/cookbooks/example_cookbook/Berksfile +0 -1
- data/spec/fixtures/cookbooks/example_cookbook/Berksfile.lock +0 -3
- data/spec/fixtures/cookbooks/example_cookbook/README.md +0 -12
- data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +0 -3
- data/spec/fixtures/cookbooks/example_cookbook/recipes/default.rb +0 -8
- data/spec/spec_helper.rb +0 -43
- data/spec/unit/artifactory_spec.rb +0 -64
- data/spec/unit/artifactserver_spec.rb +0 -116
- data/spec/unit/base_spec.rb +0 -87
- data/spec/unit/chef_server_artifact_spec.rb +0 -110
- data/spec/unit/chef_server_spec.rb +0 -108
- data/spec/unit/exceptions_spec.rb +0 -87
- data/spec/unit/git_spec.rb +0 -290
- data/spec/unit/metadata_based_installer_spec.rb +0 -137
- data/spec/unit/path_spec.rb +0 -119
data/spec/spec_helper.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require "cookbook-omnifetch"
|
2
|
-
|
3
|
-
module Fixtures
|
4
|
-
|
5
|
-
def fixtures_path
|
6
|
-
spec_root.join("fixtures")
|
7
|
-
end
|
8
|
-
|
9
|
-
def spec_root
|
10
|
-
Pathname.new(File.expand_path(File.dirname(__FILE__)))
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
module MockShellOut; end
|
16
|
-
module MockCachedCookbook; end
|
17
|
-
|
18
|
-
RSpec.configure do |config|
|
19
|
-
|
20
|
-
config.raise_errors_for_deprecations!
|
21
|
-
|
22
|
-
config.include Fixtures
|
23
|
-
|
24
|
-
config.expect_with :rspec do |c|
|
25
|
-
c.syntax = [:expect]
|
26
|
-
end
|
27
|
-
config.mock_with :rspec do |c|
|
28
|
-
c.syntax = [:expect, :should]
|
29
|
-
end
|
30
|
-
|
31
|
-
config.filter_run :focus => true
|
32
|
-
|
33
|
-
config.run_all_when_everything_filtered = true
|
34
|
-
|
35
|
-
config.before(:suite) do
|
36
|
-
CookbookOmnifetch.configure do |c|
|
37
|
-
c.cache_path = File.expand_path("~/.berkshelf")
|
38
|
-
c.storage_path = Pathname.new(File.expand_path("~/.berkshelf/cookbooks"))
|
39
|
-
c.shell_out_class = MockShellOut
|
40
|
-
c.cached_cookbook_class = MockCachedCookbook
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "cookbook-omnifetch/artifactory"
|
3
|
-
require "zlib"
|
4
|
-
require "archive/tar/minitar"
|
5
|
-
|
6
|
-
module CookbookOmnifetch
|
7
|
-
describe ArtifactoryLocation do
|
8
|
-
|
9
|
-
let(:cookbook_name) { "nginx" }
|
10
|
-
|
11
|
-
let(:cookbook_version) { "1.5.23" }
|
12
|
-
|
13
|
-
let(:http_client) { double("Chef::HTTP::Simple") }
|
14
|
-
|
15
|
-
let(:constraint) { double("Constraint") }
|
16
|
-
|
17
|
-
let(:dependency) { double("Dependency", name: cookbook_name, constraint: constraint) }
|
18
|
-
|
19
|
-
let(:url) { "https://artifactory.example.com/api/v1/cookbooks/nginx/versions/1.5.23/download" }
|
20
|
-
|
21
|
-
let(:options) { { artifactory: url, version: cookbook_version, http_client: http_client } }
|
22
|
-
|
23
|
-
subject(:public_repo_location) { described_class.new(dependency, options) }
|
24
|
-
|
25
|
-
it "has a URI" do
|
26
|
-
expect(public_repo_location.uri).to eq(url)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "has a repo host" do
|
30
|
-
expect(public_repo_location.repo_host).to eq("artifactory.example.com")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "has an exact version" do
|
34
|
-
expect(public_repo_location.cookbook_version).to eq("1.5.23")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "has a cache key containing the site URI and version" do
|
38
|
-
expect(public_repo_location.cache_key).to eq("nginx-1.5.23-artifactory.example.com")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "sets the install location as the cache path plus cache key" do
|
42
|
-
expected_install_path = Pathname.new("~/.berkshelf/cookbooks").expand_path.join("nginx-1.5.23-artifactory.example.com")
|
43
|
-
expect(public_repo_location.install_path).to eq(expected_install_path)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "considers the cookbook installed if it exists in the main cache" do
|
47
|
-
expect(public_repo_location.install_path).to receive(:exist?).and_return(true)
|
48
|
-
expect(public_repo_location.installed?).to be true
|
49
|
-
end
|
50
|
-
|
51
|
-
it "considers the cookbook not installed if it doesn't exist in the main cache" do
|
52
|
-
expect(public_repo_location.install_path).to receive(:exist?).and_return(false)
|
53
|
-
expect(public_repo_location.installed?).to be false
|
54
|
-
end
|
55
|
-
|
56
|
-
it "provides lock data as a Hash" do
|
57
|
-
expected_data = {
|
58
|
-
"artifactory" => url,
|
59
|
-
"version" => "1.5.23",
|
60
|
-
}
|
61
|
-
expect(public_repo_location.lock_data).to eq(expected_data)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,116 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "cookbook-omnifetch/artifactserver"
|
3
|
-
require "zlib"
|
4
|
-
require "archive/tar/minitar"
|
5
|
-
|
6
|
-
module CookbookOmnifetch
|
7
|
-
describe ArtifactserverLocation do
|
8
|
-
|
9
|
-
let(:cookbook_name) { "nginx" }
|
10
|
-
|
11
|
-
let(:cookbook_version) { "1.5.23" }
|
12
|
-
|
13
|
-
let(:constraint) { double("Constraint") }
|
14
|
-
|
15
|
-
let(:dependency) { double("Dependency", name: cookbook_name, constraint: constraint) }
|
16
|
-
|
17
|
-
let(:url) { "https://supermarket.getchef.com/api/v1/cookbooks/nginx/versions/1.5.23/download" }
|
18
|
-
|
19
|
-
let(:options) { { artifactserver: url, version: cookbook_version } }
|
20
|
-
|
21
|
-
subject(:public_repo_location) { described_class.new(dependency, options) }
|
22
|
-
|
23
|
-
it "has a URI" do
|
24
|
-
expect(public_repo_location.uri).to eq(url)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "has a repo host" do
|
28
|
-
expect(public_repo_location.repo_host).to eq("supermarket.getchef.com")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "has an exact version" do
|
32
|
-
expect(public_repo_location.cookbook_version).to eq("1.5.23")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "has a cache key containing the site URI and version" do
|
36
|
-
expect(public_repo_location.cache_key).to eq("nginx-1.5.23-supermarket.getchef.com")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "sets the install location as the cache path plus cache key" do
|
40
|
-
expected_install_path = Pathname.new("~/.berkshelf/cookbooks").expand_path.join("nginx-1.5.23-supermarket.getchef.com")
|
41
|
-
expect(public_repo_location.install_path).to eq(expected_install_path)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "considers the cookbook installed if it exists in the main cache" do
|
45
|
-
expect(public_repo_location.install_path).to receive(:exist?).and_return(true)
|
46
|
-
expect(public_repo_location.installed?).to be true
|
47
|
-
end
|
48
|
-
|
49
|
-
it "considers the cookbook not installed if it doesn't exist in the main cache" do
|
50
|
-
expect(public_repo_location.install_path).to receive(:exist?).and_return(false)
|
51
|
-
expect(public_repo_location.installed?).to be false
|
52
|
-
end
|
53
|
-
|
54
|
-
it "provides lock data as a Hash" do
|
55
|
-
expected_data = {
|
56
|
-
"artifactserver" => url,
|
57
|
-
"version" => "1.5.23",
|
58
|
-
}
|
59
|
-
expect(public_repo_location.lock_data).to eq(expected_data)
|
60
|
-
end
|
61
|
-
|
62
|
-
context "when asked to install a new cookbook" do
|
63
|
-
|
64
|
-
let(:http_client) { double("Http Client") }
|
65
|
-
|
66
|
-
let(:test_root) { Dir.mktmpdir(nil) }
|
67
|
-
|
68
|
-
let(:storage_path) { File.join(test_root, "storage") }
|
69
|
-
|
70
|
-
let(:cache_path) { File.join(test_root, "cache") }
|
71
|
-
|
72
|
-
let(:cookbook_fixtures_path) { fixtures_path.join("cookbooks") }
|
73
|
-
|
74
|
-
let(:cookbook_name) { "example_cookbook" }
|
75
|
-
|
76
|
-
let(:cookbook_version) { "0.5.0" }
|
77
|
-
|
78
|
-
let(:cookbook_tarball_handle) do
|
79
|
-
gz_file_name = File.join(test_root, "input.gz")
|
80
|
-
Zlib::GzipWriter.open(gz_file_name) do |gz|
|
81
|
-
# Minitar writes the full paths provided and doesn't seem to have a way to
|
82
|
-
# remove prefixes. So we chdir like barbarians.
|
83
|
-
Dir.chdir(cookbook_fixtures_path) do
|
84
|
-
Archive::Tar::Minitar.pack(cookbook_name, gz)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
File.open(gz_file_name)
|
88
|
-
end
|
89
|
-
|
90
|
-
let(:cookbook_files) { %w{. .. .gitignore .kitchen.yml Berksfile Berksfile.lock metadata.rb README.md recipes} }
|
91
|
-
|
92
|
-
before do
|
93
|
-
allow(CookbookOmnifetch).to receive(:storage_path).and_return(Pathname.new(storage_path))
|
94
|
-
allow(CookbookOmnifetch).to receive(:cache_path).and_return(cache_path)
|
95
|
-
FileUtils.mkdir_p(storage_path)
|
96
|
-
end
|
97
|
-
|
98
|
-
after do
|
99
|
-
FileUtils.rm_r(test_root)
|
100
|
-
end
|
101
|
-
|
102
|
-
it "installs the cookbook to the desired install path" do
|
103
|
-
expect(public_repo_location).to receive(:http_client).and_return(http_client)
|
104
|
-
expect(cookbook_tarball_handle).to receive(:close).and_call_original
|
105
|
-
expect(http_client).to receive(:streaming_request).with(nil).and_yield(cookbook_tarball_handle)
|
106
|
-
expect(public_repo_location).to receive(:validate_cached!)
|
107
|
-
|
108
|
-
public_repo_location.install
|
109
|
-
|
110
|
-
expect(File).to exist(public_repo_location.cache_path)
|
111
|
-
expect(Dir).to exist(public_repo_location.install_path)
|
112
|
-
expect(Dir.entries(public_repo_location.install_path)).to match_array(cookbook_files)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
data/spec/unit/base_spec.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "cookbook-omnifetch/base"
|
3
|
-
|
4
|
-
module CookbookOmnifetch
|
5
|
-
describe BaseLocation do
|
6
|
-
let(:constraint) { double("constraint") }
|
7
|
-
let(:dependency) { double("dependency", name: "cookbook", version_constraint: constraint) }
|
8
|
-
|
9
|
-
subject { described_class.new(dependency) }
|
10
|
-
|
11
|
-
describe "#installed?" do
|
12
|
-
it "is an abstract function" do
|
13
|
-
expect { subject.installed? }.to raise_error(AbstractFunction)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#install" do
|
18
|
-
it "is an abstract function" do
|
19
|
-
expect { subject.install }.to raise_error(AbstractFunction)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#cached_cookbook" do
|
24
|
-
it "is an abstract function" do
|
25
|
-
expect { subject.cached_cookbook }.to raise_error(AbstractFunction)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#to_lock" do
|
30
|
-
it "is an abstract function" do
|
31
|
-
expect { subject.to_lock }.to raise_error(AbstractFunction)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#lock_data" do
|
36
|
-
it "is an abstract function" do
|
37
|
-
expect { subject.lock_data }.to raise_error(AbstractFunction)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#validate_cached!" do
|
42
|
-
context "when the path is not a cookbook" do
|
43
|
-
before { CookbookOmnifetch.stub(:cookbook?).and_return(false) }
|
44
|
-
|
45
|
-
it "raises an error" do
|
46
|
-
expect do
|
47
|
-
subject.validate_cached!("/foo/bar")
|
48
|
-
end.to raise_error(NotACookbook)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when the path is a cookbook" do
|
53
|
-
let(:cookbook) do
|
54
|
-
double("cookbook",
|
55
|
-
cookbook_name: "cookbook",
|
56
|
-
version: "0.1.0"
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
before do
|
61
|
-
CookbookOmnifetch.stub(:cookbook?).and_return(true)
|
62
|
-
MockCachedCookbook.stub(:from_path).and_return(cookbook)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "raises an error if the constraint does not satisfy" do
|
66
|
-
constraint.stub(:satisfies?).with("0.1.0").and_return(false)
|
67
|
-
expect do
|
68
|
-
subject.validate_cached!(cookbook)
|
69
|
-
end.to raise_error(CookbookValidationFailure)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "raises an error if the names do not match" do
|
73
|
-
constraint.stub(:satisfies?).with("0.1.0").and_return(true)
|
74
|
-
cookbook.stub(:cookbook_name).and_return("different_name")
|
75
|
-
expect do
|
76
|
-
subject.validate_cached!(cookbook)
|
77
|
-
end.to raise_error(MismatchedCookbookName)
|
78
|
-
end
|
79
|
-
|
80
|
-
it "returns true when the validation succeeds" do
|
81
|
-
constraint.stub(:satisfies?).with("0.1.0").and_return(true)
|
82
|
-
expect(subject.validate_cached!(cookbook)).to be true
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "cookbook-omnifetch/chef_server.rb"
|
3
|
-
|
4
|
-
RSpec.describe CookbookOmnifetch::ChefServerArtifactLocation do
|
5
|
-
|
6
|
-
let(:http_client) { double("Http Client") }
|
7
|
-
|
8
|
-
let(:test_root) { "/some/fake/path" }
|
9
|
-
|
10
|
-
let(:storage_path) { File.join(test_root, "storage") }
|
11
|
-
|
12
|
-
let(:dependency) { double("Dependency", name: cookbook_name) }
|
13
|
-
|
14
|
-
let(:cookbook_name) { "example" }
|
15
|
-
|
16
|
-
let(:cookbook_identifier) { "467dc855408ce8b74f991c5dc2fd72a6aa369b60" }
|
17
|
-
|
18
|
-
let(:url) { "https://chef.example.com/organizations/example" }
|
19
|
-
|
20
|
-
let(:options) { { chef_server_artifact: url, identifier: cookbook_identifier, http_client: http_client } }
|
21
|
-
|
22
|
-
let(:expected_cache_key) { "example-467dc855408ce8b74f991c5dc2fd72a6aa369b60" }
|
23
|
-
|
24
|
-
let(:expected_install_path) { File.join(storage_path, expected_cache_key) }
|
25
|
-
|
26
|
-
subject(:chef_server_artifact_location) { described_class.new(dependency, options) }
|
27
|
-
|
28
|
-
before do
|
29
|
-
allow(CookbookOmnifetch).to receive(:storage_path).and_return(Pathname.new(storage_path))
|
30
|
-
end
|
31
|
-
|
32
|
-
it "has a URI" do
|
33
|
-
expect(chef_server_artifact_location.uri).to eq(url)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "has an HTTP client" do
|
37
|
-
expect(chef_server_artifact_location.http_client).to eq(http_client)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "has a metadata_based_installer" do
|
41
|
-
installer = chef_server_artifact_location.installer
|
42
|
-
expect(installer).to be_a(CookbookOmnifetch::MetadataBasedInstaller)
|
43
|
-
expect(installer.http_client).to eq(http_client)
|
44
|
-
expect(installer.url_path).to eq("/cookbook_artifacts/example/467dc855408ce8b74f991c5dc2fd72a6aa369b60")
|
45
|
-
expect(installer.install_path.to_s).to eq(expected_install_path)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "has a cache key containing the site URI and version" do
|
49
|
-
expect(chef_server_artifact_location.cache_key).to eq(expected_cache_key)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "has an identifier" do
|
53
|
-
expect(chef_server_artifact_location.cookbook_identifier).to eq(cookbook_identifier)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "provides lock data as a Hash" do
|
57
|
-
expected_data = {
|
58
|
-
"chef_server_artifact" => url,
|
59
|
-
"identifier" => cookbook_identifier,
|
60
|
-
}
|
61
|
-
expect(chef_server_artifact_location.lock_data).to eq(expected_data)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "returns a cached cookbook object" do
|
65
|
-
expect(MockCachedCookbook).to receive(:from_path).with(Pathname.new(expected_install_path))
|
66
|
-
chef_server_artifact_location.cached_cookbook
|
67
|
-
end
|
68
|
-
|
69
|
-
context "when using the default chef server HTTP client" do
|
70
|
-
|
71
|
-
let(:options) { { chef_server_artifact: url, identifier: cookbook_identifier } }
|
72
|
-
|
73
|
-
let(:default_http_client) { double("Http Client") }
|
74
|
-
|
75
|
-
before do
|
76
|
-
CookbookOmnifetch.integration.default_chef_server_http_client = default_http_client
|
77
|
-
end
|
78
|
-
|
79
|
-
after do
|
80
|
-
CookbookOmnifetch.integration.default_chef_server_http_client = nil
|
81
|
-
end
|
82
|
-
|
83
|
-
it "uses the default http client for requests" do
|
84
|
-
expect(chef_server_artifact_location.http_client).to eq(default_http_client)
|
85
|
-
end
|
86
|
-
|
87
|
-
context "and an http client is explicitly passed" do
|
88
|
-
|
89
|
-
let(:options) { { chef_server: url, identifier: cookbook_identifier, http_client: http_client } }
|
90
|
-
|
91
|
-
it "uses the explicitly passed client instead of the default" do
|
92
|
-
expect(chef_server_artifact_location.http_client).to eq(http_client)
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "when installing" do
|
99
|
-
|
100
|
-
let(:installer) { instance_double("CookbookOmnifetch::MetadataBasedInstaller") }
|
101
|
-
|
102
|
-
it "delegates to the MetadataBasedInstaller" do
|
103
|
-
allow(chef_server_artifact_location).to receive(:installer).and_return(installer)
|
104
|
-
expect(installer).to receive(:install)
|
105
|
-
chef_server_artifact_location.install
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "cookbook-omnifetch/chef_server.rb"
|
3
|
-
|
4
|
-
RSpec.describe CookbookOmnifetch::ChefServerLocation do
|
5
|
-
|
6
|
-
let(:http_client) { double("Http Client") }
|
7
|
-
|
8
|
-
let(:test_root) { "/some/fake/path" }
|
9
|
-
|
10
|
-
let(:storage_path) { File.join(test_root, "storage") }
|
11
|
-
|
12
|
-
let(:dependency) { double("Dependency", name: cookbook_name) }
|
13
|
-
|
14
|
-
let(:cookbook_name) { "example" }
|
15
|
-
|
16
|
-
let(:cookbook_version) { "0.5.0" }
|
17
|
-
|
18
|
-
let(:url) { "https://chef.example.com/organizations/example" }
|
19
|
-
|
20
|
-
let(:options) { { chef_server: url, version: cookbook_version, http_client: http_client } }
|
21
|
-
|
22
|
-
let(:expected_install_path) { File.join(storage_path, "example-0.5.0") }
|
23
|
-
|
24
|
-
subject(:chef_server_location) { described_class.new(dependency, options) }
|
25
|
-
|
26
|
-
before do
|
27
|
-
allow(CookbookOmnifetch).to receive(:storage_path).and_return(Pathname.new(storage_path))
|
28
|
-
end
|
29
|
-
|
30
|
-
it "has a URI" do
|
31
|
-
expect(chef_server_location.uri).to eq(url)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "has an HTTP client" do
|
35
|
-
expect(chef_server_location.http_client).to eq(http_client)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "has a metadata_based_installer" do
|
39
|
-
installer = chef_server_location.installer
|
40
|
-
expect(installer).to be_a(CookbookOmnifetch::MetadataBasedInstaller)
|
41
|
-
expect(installer.http_client).to eq(http_client)
|
42
|
-
expect(installer.url_path).to eq("/cookbooks/example/0.5.0")
|
43
|
-
expect(installer.install_path.to_s).to eq(expected_install_path)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "has a cache key containing the site URI and version" do
|
47
|
-
expect(chef_server_location.cache_key).to eq("example-0.5.0")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "has an exact version" do
|
51
|
-
expect(chef_server_location.cookbook_version).to eq("0.5.0")
|
52
|
-
end
|
53
|
-
|
54
|
-
it "provides lock data as a Hash" do
|
55
|
-
expected_data = {
|
56
|
-
"chef_server" => url,
|
57
|
-
"version" => "0.5.0",
|
58
|
-
}
|
59
|
-
expect(chef_server_location.lock_data).to eq(expected_data)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "returns a cached cookbook object" do
|
63
|
-
expect(MockCachedCookbook).to receive(:from_path).with(Pathname.new(expected_install_path))
|
64
|
-
chef_server_location.cached_cookbook
|
65
|
-
end
|
66
|
-
|
67
|
-
context "when using the default chef server HTTP client" do
|
68
|
-
|
69
|
-
let(:options) { { chef_server_artifact: url, version: cookbook_version } }
|
70
|
-
|
71
|
-
let(:default_http_client) { double("Http Client") }
|
72
|
-
|
73
|
-
before do
|
74
|
-
CookbookOmnifetch.integration.default_chef_server_http_client = default_http_client
|
75
|
-
end
|
76
|
-
|
77
|
-
after do
|
78
|
-
CookbookOmnifetch.integration.default_chef_server_http_client = nil
|
79
|
-
end
|
80
|
-
|
81
|
-
it "uses the default http client for requests" do
|
82
|
-
expect(chef_server_location.http_client).to eq(default_http_client)
|
83
|
-
end
|
84
|
-
|
85
|
-
context "and an http client is explicitly passed" do
|
86
|
-
|
87
|
-
let(:options) { { chef_server: url, version: cookbook_version, http_client: http_client } }
|
88
|
-
|
89
|
-
it "uses the explicitly passed client instead of the default" do
|
90
|
-
expect(chef_server_location.http_client).to eq(http_client)
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "when installing" do
|
97
|
-
|
98
|
-
let(:installer) { instance_double("CookbookOmnifetch::MetadataBasedInstaller") }
|
99
|
-
|
100
|
-
it "delegates to the MetadataBasedInstaller" do
|
101
|
-
allow(chef_server_location).to receive(:installer).and_return(installer)
|
102
|
-
expect(installer).to receive(:install)
|
103
|
-
chef_server_location.install
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|