berkshelf 6.3.4 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +10 -0
- data/.travis.yml +6 -8
- data/CHANGELOG.md +7 -19
- data/Gemfile +10 -0
- data/Gemfile.lock +68 -103
- data/Thorfile +2 -2
- data/berkshelf.gemspec +6 -8
- data/features/commands/info.feature +50 -8
- data/features/commands/shelf/show.feature +10 -40
- data/features/commands/upload.feature +73 -0
- data/features/commands/vendor.feature +43 -0
- data/features/json_formatter.feature +1 -1
- data/features/step_definitions/chef_server_steps.rb +2 -2
- data/features/step_definitions/filesystem_steps.rb +16 -0
- data/features/support/env.rb +11 -10
- data/lib/berkshelf.rb +15 -20
- data/lib/berkshelf/berksfile.rb +57 -47
- data/lib/berkshelf/cached_cookbook.rb +120 -19
- data/lib/berkshelf/chef_config_compat.rb +50 -0
- data/lib/berkshelf/chef_repo_universe.rb +2 -2
- data/lib/berkshelf/cli.rb +3 -42
- data/lib/berkshelf/community_rest.rb +40 -61
- data/lib/berkshelf/config.rb +92 -118
- data/lib/berkshelf/cookbook_store.rb +3 -2
- data/lib/berkshelf/core_ext/file.rb +1 -1
- data/lib/berkshelf/dependency.rb +1 -10
- data/lib/berkshelf/downloader.rb +19 -7
- data/lib/berkshelf/errors.rb +3 -0
- data/lib/berkshelf/location.rb +1 -1
- data/lib/berkshelf/locations/base.rb +1 -1
- data/lib/berkshelf/lockfile.rb +17 -13
- data/lib/berkshelf/logger.rb +62 -1
- data/lib/berkshelf/packager.rb +1 -1
- data/lib/berkshelf/resolver.rb +1 -1
- data/lib/berkshelf/ridley_compat.rb +22 -3
- data/lib/berkshelf/uploader.rb +76 -48
- data/lib/berkshelf/version.rb +1 -1
- data/spec/fixtures/cookbook-path-uploader/apt-2.3.6/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/build-essential-1.4.2/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/jenkins-2.0.3/metadata.rb +5 -0
- data/spec/fixtures/cookbook-path-uploader/jenkins-config-0.1.0/metadata.rb +4 -0
- data/spec/fixtures/cookbook-path-uploader/runit-1.5.8/metadata.rb +5 -0
- data/spec/fixtures/cookbook-path-uploader/yum-3.0.6/metadata.rb +2 -0
- data/spec/fixtures/cookbook-path-uploader/yum-epel-0.2.0/metadata.rb +3 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/support/chef_api.rb +4 -4
- data/spec/support/chef_server.rb +1 -1
- data/spec/support/matchers/file_system_matchers.rb +1 -3
- data/spec/support/path_helpers.rb +1 -1
- data/spec/unit/berkshelf/berksfile_spec.rb +3 -24
- data/spec/unit/berkshelf/cached_cookbook_spec.rb +13 -15
- data/spec/unit/berkshelf/community_rest_spec.rb +3 -12
- data/spec/unit/berkshelf/config_spec.rb +4 -4
- data/spec/unit/berkshelf/downloader_spec.rb +6 -11
- data/spec/unit/berkshelf/lockfile_spec.rb +10 -7
- data/spec/unit/berkshelf/source_spec.rb +1 -1
- data/spec/unit/berkshelf/ssl_policies_spec.rb +2 -5
- data/spec/unit/berkshelf/uploader_spec.rb +60 -10
- data/spec/unit/berkshelf/visualizer_spec.rb +2 -2
- metadata +49 -102
- data/features/commands/cookbook.feature +0 -35
- data/features/commands/init.feature +0 -27
- data/features/config.feature +0 -111
- data/lib/berkshelf/base_generator.rb +0 -42
- data/lib/berkshelf/cookbook_generator.rb +0 -133
- data/lib/berkshelf/init_generator.rb +0 -195
- data/lib/berkshelf/streaming_file_adapter.rb +0 -22
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -108
- data/spec/unit/berkshelf/init_generator_spec.rb +0 -265
data/lib/berkshelf/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,6 @@ require "rspec"
|
|
8
8
|
require "cleanroom/rspec"
|
9
9
|
require "webmock/rspec"
|
10
10
|
require "rspec/its"
|
11
|
-
require "berkshelf"
|
12
11
|
|
13
12
|
Dir["spec/support/**/*.rb"].each { |f| require File.expand_path(f) }
|
14
13
|
|
@@ -64,6 +63,8 @@ def capture(stream)
|
|
64
63
|
result
|
65
64
|
end
|
66
65
|
|
66
|
+
require "berkshelf"
|
67
|
+
|
67
68
|
module Berkshelf
|
68
69
|
class GitLocation
|
69
70
|
include Berkshelf::RSpec::Git
|
@@ -71,7 +72,6 @@ module Berkshelf
|
|
71
72
|
alias :real_clone :clone
|
72
73
|
def clone
|
73
74
|
fake_remote = generate_fake_git_remote(uri, tags: @branch ? [@branch] : [])
|
74
|
-
tmp_clone = File.join(self.class.tmpdir, uri.gsub(/[\/:]/, "-"))
|
75
75
|
@uri = "file://#{fake_remote}"
|
76
76
|
real_clone
|
77
77
|
end
|
data/spec/support/chef_api.rb
CHANGED
@@ -83,14 +83,14 @@ module Berkshelf
|
|
83
83
|
end.join("\n")
|
84
84
|
|
85
85
|
if options[:dependencies]
|
86
|
-
options[:dependencies].each do |
|
87
|
-
metadata << "depends '#{
|
86
|
+
options[:dependencies].each do |dep_name, constraint|
|
87
|
+
metadata << "depends '#{dep_name}', '#{constraint}'\n"
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
if options[:recommendations]
|
92
|
-
options[:recommendations].each do |
|
93
|
-
metadata << "recommends '#{
|
92
|
+
options[:recommendations].each do |rec_name, constraint|
|
93
|
+
metadata << "recommends '#{rec_name}', '#{constraint}'\n"
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
data/spec/support/chef_server.rb
CHANGED
@@ -192,26 +192,6 @@ describe Berkshelf::Berksfile do
|
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
describe "#site" do
|
196
|
-
it "raises a Berkshelf::Deprecated error" do
|
197
|
-
expect { subject.site }.to raise_error(Berkshelf::DeprecatedError)
|
198
|
-
end
|
199
|
-
|
200
|
-
it "is a DSL method" do
|
201
|
-
expect(subject).to have_exposed_method(:site)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "#chef_api" do
|
206
|
-
it "raises a Berkshelf::Deprecated error" do
|
207
|
-
expect { subject.chef_api }.to raise_error(Berkshelf::DeprecatedError)
|
208
|
-
end
|
209
|
-
|
210
|
-
it "is a DSL method" do
|
211
|
-
expect(subject).to have_exposed_method(:chef_api)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
195
|
describe "#extension" do
|
216
196
|
it "is a DSL method" do
|
217
197
|
expect(subject).to have_exposed_method(:extension)
|
@@ -385,12 +365,12 @@ describe Berkshelf::Berksfile do
|
|
385
365
|
end
|
386
366
|
|
387
367
|
describe "#vendor" do
|
388
|
-
let(:cached_cookbook) {
|
389
|
-
let(:installer) {
|
368
|
+
let(:cached_cookbook) { instance_double(Berkshelf::CachedCookbook, cookbook_name: "my_cookbook", path: "/my_cookbook/path", compile_metadata: true, reload: nil) }
|
369
|
+
let(:installer) { instance_double(Berkshelf::Installer, run: [cached_cookbook]) }
|
390
370
|
let(:raw_metadata_files) { [File.join(cached_cookbook.cookbook_name, "metadata.rb")] }
|
391
371
|
|
392
372
|
let(:destination) { "/a/destination/path" }
|
393
|
-
let(:options) { { :exclude =>
|
373
|
+
let(:options) { { :exclude => Berkshelf::Berksfile::EXCLUDED_VCS_FILES_WHEN_VENDORING, delete: nil } }
|
394
374
|
|
395
375
|
before do
|
396
376
|
allow(Berkshelf::Installer).to receive(:new).and_return(installer)
|
@@ -404,7 +384,6 @@ describe Berkshelf::Berksfile do
|
|
404
384
|
|
405
385
|
it "excludes the top-level metadata.rb file" do
|
406
386
|
expect(options[:exclude].any? { |exclude| File.fnmatch?(exclude, "my_cookbook/recipes/metadata.rb", File::FNM_DOTMATCH) }).to be(false)
|
407
|
-
expect(options[:exclude].any? { |exclude| File.fnmatch?(exclude, "my_cookbook/metadata.rb", File::FNM_DOTMATCH) }).to be(true)
|
408
387
|
end
|
409
388
|
end
|
410
389
|
|
@@ -76,17 +76,13 @@ describe Berkshelf::CachedCookbook do
|
|
76
76
|
expect(subject.dependencies).to include(dependencies)
|
77
77
|
end
|
78
78
|
|
79
|
-
it "contains recommendations from the cookbook metadata" do
|
80
|
-
expect(subject.dependencies).to include(recommendations)
|
81
|
-
end
|
82
|
-
|
83
79
|
it "returns a hash" do
|
84
80
|
expect(subject.dependencies).to be_a(Hash)
|
85
81
|
end
|
86
82
|
end
|
87
83
|
|
88
84
|
describe "#pretty_hash" do
|
89
|
-
shared_examples "a pretty_hash cookbook attribute" do |attribute, key|
|
85
|
+
shared_examples "a pretty_hash string cookbook attribute" do |attribute, key|
|
90
86
|
it "is not present when the `#{attribute}` attribute is nil" do
|
91
87
|
allow(subject).to receive(attribute.to_sym).and_return(nil)
|
92
88
|
expect(subject.pretty_hash).to_not have_key((key || attribute).to_sym)
|
@@ -96,9 +92,11 @@ describe Berkshelf::CachedCookbook do
|
|
96
92
|
allow(subject).to receive(attribute.to_sym).and_return("")
|
97
93
|
expect(subject.pretty_hash).to_not have_key((key || attribute).to_sym)
|
98
94
|
end
|
95
|
+
end
|
99
96
|
|
100
|
-
|
101
|
-
|
97
|
+
shared_examples "a pretty_hash hash cookbook attribute" do |attribute, key|
|
98
|
+
it "is not present when the `#{attribute}` attribute is nil" do
|
99
|
+
allow(subject).to receive(attribute.to_sym).and_return(nil)
|
102
100
|
expect(subject.pretty_hash).to_not have_key((key || attribute).to_sym)
|
103
101
|
end
|
104
102
|
|
@@ -113,13 +111,13 @@ describe Berkshelf::CachedCookbook do
|
|
113
111
|
end
|
114
112
|
end
|
115
113
|
|
116
|
-
it_behaves_like "a pretty_hash cookbook attribute", "cookbook_name", "name"
|
117
|
-
it_behaves_like "a pretty_hash cookbook attribute", "version"
|
118
|
-
it_behaves_like "a pretty_hash cookbook attribute", "description"
|
119
|
-
it_behaves_like "a pretty_hash cookbook attribute", "maintainer", "author"
|
120
|
-
it_behaves_like "a pretty_hash cookbook attribute", "maintainer_email", "email"
|
121
|
-
it_behaves_like "a pretty_hash cookbook attribute", "license"
|
122
|
-
it_behaves_like "a pretty_hash cookbook attribute", "platforms"
|
123
|
-
it_behaves_like "a pretty_hash cookbook attribute", "dependencies"
|
114
|
+
it_behaves_like "a pretty_hash string cookbook attribute", "cookbook_name", "name"
|
115
|
+
it_behaves_like "a pretty_hash string cookbook attribute", "version"
|
116
|
+
it_behaves_like "a pretty_hash string cookbook attribute", "description"
|
117
|
+
it_behaves_like "a pretty_hash string cookbook attribute", "maintainer", "author"
|
118
|
+
it_behaves_like "a pretty_hash string cookbook attribute", "maintainer_email", "email"
|
119
|
+
it_behaves_like "a pretty_hash string cookbook attribute", "license"
|
120
|
+
it_behaves_like "a pretty_hash hash cookbook attribute", "platforms"
|
121
|
+
it_behaves_like "a pretty_hash hash cookbook attribute", "dependencies"
|
124
122
|
end
|
125
123
|
end
|
@@ -29,7 +29,7 @@ describe Berkshelf::CommunityREST do
|
|
29
29
|
expect(Berkshelf::CommunityREST.uri_escape_version(nil)).to be_a(String)
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it "converts a version to it's underscored version" do
|
33
33
|
expect(Berkshelf::CommunityREST.uri_escape_version("1.1.2")).to eq("1_1_2")
|
34
34
|
end
|
35
35
|
|
@@ -64,14 +64,6 @@ describe Berkshelf::CommunityREST do
|
|
64
64
|
let(:api_uri) { Berkshelf::CommunityREST::V1_API }
|
65
65
|
subject { Berkshelf::CommunityREST.new(api_uri) }
|
66
66
|
|
67
|
-
describe "#initialize" do
|
68
|
-
context "Faraday handlers" do
|
69
|
-
it "includes follow_redirects to prevent 301 from community, stopping some cookbooks installing" do
|
70
|
-
expect(subject.builder.handlers).to include(Ridley::Middleware::FollowRedirects)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
67
|
describe "#download" do
|
76
68
|
let(:archive) { double("archive", path: "/foo/bar", unlink: true) }
|
77
69
|
|
@@ -93,7 +85,6 @@ describe Berkshelf::CommunityREST do
|
|
93
85
|
.and_return("/foo/nginx")
|
94
86
|
.once
|
95
87
|
expect(archive).to receive(:unlink).once
|
96
|
-
expect(Dir).to receive(:chdir).with("/foo/nginx")
|
97
88
|
|
98
89
|
subject.download("bacon", "1.0.0")
|
99
90
|
end
|
@@ -109,8 +100,8 @@ describe Berkshelf::CommunityREST do
|
|
109
100
|
|
110
101
|
result = subject.find("bacon", "1.0.0")
|
111
102
|
|
112
|
-
expect(result
|
113
|
-
expect(result
|
103
|
+
expect(result["cookbook"]).to eq("/path/to/cookbook")
|
104
|
+
expect(result["version"]).to eq("1.0.0")
|
114
105
|
end
|
115
106
|
|
116
107
|
it "raises a CookbookNotFound error on a 404 response for a non-existent cookbook" do
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Berkshelf::Config do
|
4
4
|
describe "::file" do
|
5
5
|
context "when the file does not exist" do
|
6
|
-
before { allow(File).to receive(:
|
6
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
7
7
|
|
8
8
|
it "is nil" do
|
9
9
|
expect(Berkshelf::Config.file).to be_nil
|
@@ -25,7 +25,7 @@ describe Berkshelf::Config do
|
|
25
25
|
context "a Chef config to read defaults from" do
|
26
26
|
let(:chef_config) do
|
27
27
|
double(
|
28
|
-
|
28
|
+
Berkshelf::ChefConfigCompat,
|
29
29
|
chef_server_url: "https://chef.example.com",
|
30
30
|
validation_client_name: "validator",
|
31
31
|
validation_key: "validator.pem",
|
@@ -75,7 +75,7 @@ describe Berkshelf::Config do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
before do
|
78
|
-
allow(File).to receive(:
|
78
|
+
allow(File).to receive(:exist?).and_return(false)
|
79
79
|
end
|
80
80
|
|
81
81
|
after do
|
@@ -85,7 +85,7 @@ describe Berkshelf::Config do
|
|
85
85
|
context "when ENV['BERKSHELF_CONFIG'] is used" do
|
86
86
|
before do
|
87
87
|
allow(ENV).to receive(:[]).with("BERKSHELF_CONFIG").and_return("/tmp/config.json")
|
88
|
-
allow(File).to receive(:
|
88
|
+
allow(File).to receive(:exist?).with("/tmp/config.json").and_return(true)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "points to a location within it" do
|
@@ -86,12 +86,10 @@ module Berkshelf
|
|
86
86
|
describe "chef_server location type" do
|
87
87
|
let(:chef_server_url) { "http://configured-chef-server/" }
|
88
88
|
let(:ridley_client) do
|
89
|
-
|
90
|
-
cookbook: double("cookbook", download: "fake")
|
91
|
-
)
|
89
|
+
instance_double(Berkshelf::RidleyCompat)
|
92
90
|
end
|
93
91
|
let(:chef_config) do
|
94
|
-
double(
|
92
|
+
double(Berkshelf::ChefConfigCompat,
|
95
93
|
node_name: "fake-client",
|
96
94
|
client_key: "client-key",
|
97
95
|
chef_server_url: chef_server_url,
|
@@ -101,10 +99,7 @@ module Berkshelf
|
|
101
99
|
cookbook_copyright: "user",
|
102
100
|
cookbook_email: "user@example.com",
|
103
101
|
cookbook_license: "apachev2",
|
104
|
-
trusted_certs_dir: self_signed_crt_path
|
105
|
-
knife: {
|
106
|
-
chef_guard: false,
|
107
|
-
}
|
102
|
+
trusted_certs_dir: self_signed_crt_path
|
108
103
|
)
|
109
104
|
end
|
110
105
|
|
@@ -133,7 +128,7 @@ module Berkshelf
|
|
133
128
|
cert_store: cert_store,
|
134
129
|
},
|
135
130
|
}
|
136
|
-
expect(
|
131
|
+
expect(Berkshelf::RidleyCompat).to receive(:new_client).with(credentials) { ridley_client }
|
137
132
|
subject.try_download(source, name, version)
|
138
133
|
end
|
139
134
|
|
@@ -151,7 +146,7 @@ module Berkshelf
|
|
151
146
|
cert_store: cert_store,
|
152
147
|
},
|
153
148
|
}
|
154
|
-
expect(
|
149
|
+
expect(Berkshelf::RidleyCompat).to receive(:new_client).with(credentials) { ridley_client }
|
155
150
|
subject.try_download(source, name, version)
|
156
151
|
end
|
157
152
|
end
|
@@ -170,7 +165,7 @@ module Berkshelf
|
|
170
165
|
cert_store: cert_store,
|
171
166
|
},
|
172
167
|
}
|
173
|
-
expect(
|
168
|
+
expect(Berkshelf::RidleyCompat).to receive(:new_client).with(credentials) { ridley_client }
|
174
169
|
subject.try_download(source, name, version)
|
175
170
|
end
|
176
171
|
end
|
@@ -58,7 +58,7 @@ describe Berkshelf::Lockfile do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "returns false when the file does not exist" do
|
61
|
-
allow(File).to receive(:
|
61
|
+
allow(File).to receive(:exist?).and_return(false)
|
62
62
|
expect(subject.present?).to be(false)
|
63
63
|
end
|
64
64
|
|
@@ -225,7 +225,7 @@ describe Berkshelf::Lockfile do
|
|
225
225
|
|
226
226
|
context "when the Chef environment does not exist" do
|
227
227
|
it "raises an exception" do
|
228
|
-
allow(connection).to receive(:
|
228
|
+
allow(connection).to receive(:get).and_raise(Berkshelf::APIClient::ServiceNotFound)
|
229
229
|
expect do
|
230
230
|
subject.apply("production")
|
231
231
|
end.to raise_error(Berkshelf::EnvironmentNotFound)
|
@@ -233,14 +233,17 @@ describe Berkshelf::Lockfile do
|
|
233
233
|
end
|
234
234
|
|
235
235
|
it "locks the environment cookbook versions on chef server" do
|
236
|
-
environment =
|
237
|
-
|
236
|
+
environment = instance_double(Chef::Environment)
|
237
|
+
env_hash = double(Hash)
|
238
|
+
expect(connection).to receive(:get).with("environments/production").and_return(env_hash)
|
239
|
+
expect(Chef::Environment).to receive(:from_hash).with(env_hash).and_return(environment)
|
238
240
|
|
239
|
-
expect(environment).to receive(:cookbook_versions
|
241
|
+
expect(environment).to receive(:cookbook_versions).with(
|
240
242
|
"apt" => "= 1.0.0",
|
241
243
|
"jenkins" => "= 1.4.5"
|
242
244
|
)
|
243
245
|
|
246
|
+
expect(environment).to receive(:save)
|
244
247
|
subject.apply("production")
|
245
248
|
end
|
246
249
|
end
|
@@ -294,7 +297,7 @@ describe Berkshelf::Lockfile do
|
|
294
297
|
|
295
298
|
describe "#update_environment_file" do
|
296
299
|
it "raises an exception when environment file does not exist" do
|
297
|
-
allow(File).to receive(:
|
300
|
+
allow(File).to receive(:exist?).and_return(false)
|
298
301
|
expect do
|
299
302
|
subject.update_environment_file("/broken/path", nil)
|
300
303
|
end.to raise_error(Berkshelf::EnvironmentFileNotFound)
|
@@ -307,7 +310,7 @@ describe Berkshelf::Lockfile do
|
|
307
310
|
"jenkins" => "1.4.5",
|
308
311
|
}
|
309
312
|
|
310
|
-
allow(File).to receive(:
|
313
|
+
allow(File).to receive(:exist?).and_return(true)
|
311
314
|
allow(File).to receive(:read).and_return("{}")
|
312
315
|
allow(File).to receive(:open).and_yield(file)
|
313
316
|
|
@@ -6,7 +6,7 @@ describe Berkshelf::SSLPolicy do
|
|
6
6
|
let(:self_signed_crt_path_windows_forwardslashes) { "C:/users/vagrant/.chef/trusted_certs" }
|
7
7
|
|
8
8
|
let(:chef_config) do
|
9
|
-
double(
|
9
|
+
double(Berkshelf::ChefConfigCompat,
|
10
10
|
node_name: "fake-client",
|
11
11
|
client_key: "client-key",
|
12
12
|
chef_server_url: "http://configured-chef-server/",
|
@@ -16,10 +16,7 @@ describe Berkshelf::SSLPolicy do
|
|
16
16
|
cookbook_copyright: "user",
|
17
17
|
cookbook_email: "user@example.com",
|
18
18
|
cookbook_license: "apachev2",
|
19
|
-
trusted_certs_dir: self_signed_crt_path
|
20
|
-
knife: {
|
21
|
-
chef_guard: false,
|
22
|
-
}
|
19
|
+
trusted_certs_dir: self_signed_crt_path
|
23
20
|
)
|
24
21
|
end
|
25
22
|
|
@@ -51,7 +51,7 @@ module Berkshelf
|
|
51
51
|
let(:options) { Hash.new }
|
52
52
|
|
53
53
|
let(:chef_config) do
|
54
|
-
double(
|
54
|
+
double(Berkshelf::ChefConfigCompat,
|
55
55
|
node_name: "fake-client",
|
56
56
|
client_key: "client-key",
|
57
57
|
chef_server_url: "http://configured-chef-server/",
|
@@ -61,10 +61,7 @@ module Berkshelf
|
|
61
61
|
cookbook_copyright: "user",
|
62
62
|
cookbook_email: "user@example.com",
|
63
63
|
cookbook_license: "apachev2",
|
64
|
-
trusted_certs_dir: self_signed_crt_path
|
65
|
-
knife: {
|
66
|
-
chef_guard: false,
|
67
|
-
}
|
64
|
+
trusted_certs_dir: self_signed_crt_path
|
68
65
|
)
|
69
66
|
end
|
70
67
|
|
@@ -125,7 +122,7 @@ module Berkshelf
|
|
125
122
|
end
|
126
123
|
|
127
124
|
it "uses the Berkshelf::Config options" do
|
128
|
-
expect(
|
125
|
+
expect(Berkshelf::RidleyCompat).to receive(:new_client).with(
|
129
126
|
server_url: chef_config.chef_server_url,
|
130
127
|
client_name: chef_config.node_name,
|
131
128
|
client_key: chef_config.client_key,
|
@@ -142,7 +139,7 @@ module Berkshelf
|
|
142
139
|
subject { Uploader.new(berksfile, ssl_verify: false) }
|
143
140
|
|
144
141
|
it "uses the passed option" do
|
145
|
-
expect(
|
142
|
+
expect(Berkshelf::RidleyCompat).to receive(:new_client).with(
|
146
143
|
server_url: chef_config.chef_server_url,
|
147
144
|
client_name: chef_config.node_name,
|
148
145
|
client_key: chef_config.client_key,
|
@@ -159,7 +156,7 @@ module Berkshelf
|
|
159
156
|
subject { Uploader.new(berksfile, server_url: "http://custom") }
|
160
157
|
|
161
158
|
it "uses the passed in :server_url" do
|
162
|
-
expect(
|
159
|
+
expect(Berkshelf::RidleyCompat).to receive(:new_client)
|
163
160
|
.with(include(server_url: "http://custom"))
|
164
161
|
subject.run
|
165
162
|
end
|
@@ -169,7 +166,7 @@ module Berkshelf
|
|
169
166
|
subject { Uploader.new(berksfile, client_name: "custom") }
|
170
167
|
|
171
168
|
it "uses the passed in :client_name" do
|
172
|
-
expect(
|
169
|
+
expect(Berkshelf::RidleyCompat).to receive(:new_client)
|
173
170
|
.with(include(client_name: "custom"))
|
174
171
|
subject.run
|
175
172
|
end
|
@@ -179,11 +176,64 @@ module Berkshelf
|
|
179
176
|
subject { Uploader.new(berksfile, client_key: "custom") }
|
180
177
|
|
181
178
|
it "uses the passed in :client_key" do
|
182
|
-
expect(
|
179
|
+
expect(Berkshelf::RidleyCompat).to receive(:new_client)
|
183
180
|
.with(include(client_key: "custom"))
|
184
181
|
subject.run
|
185
182
|
end
|
186
183
|
end
|
187
184
|
end
|
185
|
+
|
186
|
+
describe "#lookup_dependencies" do
|
187
|
+
before do
|
188
|
+
allow_any_instance_of(Berkshelf::Berksfile).to receive(:lockfile).and_return(lockfile)
|
189
|
+
end
|
190
|
+
|
191
|
+
let(:berksfile) { Berkshelf::Berksfile.from_file(fixtures_path.join("berksfiles/default")) }
|
192
|
+
let(:lockfile) { Berkshelf::Lockfile.from_file(fixtures_path.join("lockfiles/default.lock")) }
|
193
|
+
|
194
|
+
context "when given a cookbook that has no dependencies" do
|
195
|
+
subject { described_class.new(berksfile).send(:lookup_dependencies, "yum") }
|
196
|
+
|
197
|
+
it "returns empty array" do
|
198
|
+
expect(subject).to eq []
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context "when given a cookbook that has dependencies" do
|
203
|
+
subject { described_class.new(berksfile).send(:lookup_dependencies, "yum-epel") }
|
204
|
+
|
205
|
+
it "returns array of cookbook's dependencies" do
|
206
|
+
expect(subject).to eq ["yum"]
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
context "when given a cookbook that has dependencies which have dependencies" do
|
211
|
+
subject { described_class.new(berksfile).send(:lookup_dependencies, "runit") }
|
212
|
+
|
213
|
+
it "returns array of cookbook's dependencies and their dependencies" do
|
214
|
+
expect(subject).to eq ["build-essential", "yum", "yum-epel"]
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "#filtered_cookbooks" do
|
220
|
+
context "when iterating over a list of of cookbooks that have dependencies" do
|
221
|
+
before do
|
222
|
+
allow_any_instance_of(Berkshelf::Dependency).to receive(:berksfile).and_return(berksfile)
|
223
|
+
allow_any_instance_of(Berkshelf::Berksfile).to receive(:lockfile).and_return(lockfile)
|
224
|
+
allow(Berkshelf::CookbookStore).to receive(:instance).and_return(cookbook_store)
|
225
|
+
end
|
226
|
+
|
227
|
+
let(:berksfile) { Berkshelf::Berksfile.from_file(fixtures_path.join("berksfiles/default")) }
|
228
|
+
let(:lockfile) { Berkshelf::Lockfile.from_file(fixtures_path.join("lockfiles/default.lock")) }
|
229
|
+
let(:cookbook_store) { Berkshelf::CookbookStore.new(fixtures_path.join("cookbook-path-uploader")) }
|
230
|
+
|
231
|
+
subject { described_class.new(berksfile).send(:filtered_cookbooks) }
|
232
|
+
|
233
|
+
it "returns filtered list in correct order" do
|
234
|
+
expect(subject.map(&:name)).to eq ["yum", "yum-epel", "build-essential", "runit", "apt", "jenkins", "jenkins-config"]
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
188
238
|
end
|
189
239
|
end
|