chef 12.0.1-x86-mingw32 → 12.0.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -1
- data/lib/chef/digester.rb +1 -0
- data/lib/chef/dsl/recipe.rb +2 -1
- data/lib/chef/exceptions.rb +5 -0
- data/lib/chef/knife.rb +7 -0
- data/lib/chef/knife/cookbook_site_install.rb +34 -10
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/package/apt.rb +2 -2
- data/lib/chef/provider/package/homebrew.rb +11 -2
- data/lib/chef/provider/package/windows/msi.rb +2 -0
- data/lib/chef/provider/subversion.rb +3 -3
- data/lib/chef/resource.rb +23 -91
- data/lib/chef/resource/homebrew_package.rb +2 -1
- data/lib/chef/resource/resource_notification.rb +109 -0
- data/lib/chef/resource_collection/resource_set.rb +8 -8
- data/lib/chef/run_context.rb +4 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/whitelist.rb +3 -1
- data/lib/chef/win32/api/file.rb +17 -3
- data/spec/functional/notifications_spec.rb +169 -0
- data/spec/functional/resource/link_spec.rb +31 -32
- data/spec/support/platform_helpers.rb +5 -2
- data/spec/unit/knife/cookbook_site_install_spec.rb +157 -116
- data/spec/unit/knife_spec.rb +108 -78
- data/spec/unit/mixin/shell_out_spec.rb +39 -40
- data/spec/unit/node_spec.rb +34 -0
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/apt_spec.rb +264 -257
- data/spec/unit/provider/package/homebrew_spec.rb +26 -0
- data/spec/unit/provider/package/windows/msi_spec.rb +18 -3
- data/spec/unit/provider/subversion_spec.rb +5 -5
- data/spec/unit/provider_resolver_spec.rb +2 -2
- data/spec/unit/recipe_spec.rb +1 -0
- data/spec/unit/resource/apt_package_spec.rb +3 -5
- data/spec/unit/resource/resource_notification_spec.rb +170 -0
- data/spec/unit/resource_spec.rb +0 -151
- data/spec/unit/run_context_spec.rb +94 -55
- metadata +5 -2
@@ -23,10 +23,10 @@
|
|
23
23
|
require 'spec_helper'
|
24
24
|
|
25
25
|
describe Chef::Mixin::ShellOut do
|
26
|
-
include Chef::Mixin::ShellOut
|
27
|
-
|
26
|
+
let(:shell_out_class) { Class.new { include Chef::Mixin::ShellOut } }
|
27
|
+
subject(:shell_out_obj) { shell_out_class.new }
|
28
28
|
describe '#run_command_compatible_options' do
|
29
|
-
subject { run_command_compatible_options(command_args) }
|
29
|
+
subject { shell_out_obj.run_command_compatible_options(command_args) }
|
30
30
|
let(:command_args) { [ cmd, options ] }
|
31
31
|
let(:cmd) { "echo '#{rand(1000)}'" }
|
32
32
|
|
@@ -117,7 +117,6 @@ describe Chef::Mixin::ShellOut do
|
|
117
117
|
ENV.update(@original_env)
|
118
118
|
end
|
119
119
|
|
120
|
-
let(:shell_out) { Chef::Mixin::ShellOut }
|
121
120
|
let(:cmd) { "echo '#{rand(1000)}'" }
|
122
121
|
|
123
122
|
describe "#shell_out" do
|
@@ -126,30 +125,30 @@ describe Chef::Mixin::ShellOut do
|
|
126
125
|
describe "and environment is an option" do
|
127
126
|
it "should not change environment['LC_ALL'] when set to nil" do
|
128
127
|
options = { :environment => { 'LC_ALL' => nil } }
|
129
|
-
expect(
|
130
|
-
|
128
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
129
|
+
shell_out_obj.shell_out(cmd, options)
|
131
130
|
end
|
132
131
|
|
133
132
|
it "should not change environment['LC_ALL'] when set to non-nil" do
|
134
133
|
options = { :environment => { 'LC_ALL' => 'en_US.UTF-8' } }
|
135
|
-
expect(
|
136
|
-
|
134
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
135
|
+
shell_out_obj.shell_out(cmd, options)
|
137
136
|
end
|
138
137
|
|
139
138
|
it "should set environment['LC_ALL'] to 'en_US.UTF-8' when 'LC_ALL' not present" do
|
140
139
|
options = { :environment => { 'HOME' => '/Users/morty' } }
|
141
|
-
expect(
|
140
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
|
142
141
|
:environment => { 'HOME' => '/Users/morty', 'LC_ALL' => Chef::Config[:internal_locale] },
|
143
142
|
}).and_return(true)
|
144
|
-
|
143
|
+
shell_out_obj.shell_out(cmd, options)
|
145
144
|
end
|
146
145
|
|
147
146
|
it "should not mutate the options hash when it adds LC_ALL" do
|
148
147
|
options = { :environment => { 'HOME' => '/Users/morty' } }
|
149
|
-
expect(
|
148
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
|
150
149
|
:environment => { 'HOME' => '/Users/morty', 'LC_ALL' => Chef::Config[:internal_locale] },
|
151
150
|
}).and_return(true)
|
152
|
-
|
151
|
+
shell_out_obj.shell_out(cmd, options)
|
153
152
|
expect(options[:environment].has_key?('LC_ALL')).to be false
|
154
153
|
end
|
155
154
|
end
|
@@ -157,30 +156,30 @@ describe Chef::Mixin::ShellOut do
|
|
157
156
|
describe "and env is an option" do
|
158
157
|
it "should not change env when set to nil" do
|
159
158
|
options = { :env => { 'LC_ALL' => nil } }
|
160
|
-
expect(
|
161
|
-
|
159
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
160
|
+
shell_out_obj.shell_out(cmd, options)
|
162
161
|
end
|
163
162
|
|
164
163
|
it "should not change env when set to non-nil" do
|
165
164
|
options = { :env => { 'LC_ALL' => 'de_DE.UTF-8'}}
|
166
|
-
expect(
|
167
|
-
|
165
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
166
|
+
shell_out_obj.shell_out(cmd, options)
|
168
167
|
end
|
169
168
|
|
170
169
|
it "should set env['LC_ALL'] to 'en_US.UTF-8' when 'LC_ALL' not present" do
|
171
170
|
options = { :env => { 'HOME' => '/Users/morty' } }
|
172
|
-
expect(
|
171
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
|
173
172
|
:env => { 'HOME' => '/Users/morty', 'LC_ALL' => Chef::Config[:internal_locale] },
|
174
173
|
}).and_return(true)
|
175
|
-
|
174
|
+
shell_out_obj.shell_out(cmd, options)
|
176
175
|
end
|
177
176
|
|
178
177
|
it "should not mutate the options hash when it adds LC_ALL" do
|
179
178
|
options = { :env => { 'HOME' => '/Users/morty' } }
|
180
|
-
expect(
|
179
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
|
181
180
|
:env => { 'HOME' => '/Users/morty', 'LC_ALL' => Chef::Config[:internal_locale] },
|
182
181
|
}).and_return(true)
|
183
|
-
|
182
|
+
shell_out_obj.shell_out(cmd, options)
|
184
183
|
expect(options[:env].has_key?('LC_ALL')).to be false
|
185
184
|
end
|
186
185
|
end
|
@@ -188,20 +187,20 @@ describe Chef::Mixin::ShellOut do
|
|
188
187
|
describe "and no env/environment option is present" do
|
189
188
|
it "should add environment option and set environment['LC_ALL'] to 'en_US.UTF_8'" do
|
190
189
|
options = { :user => 'morty' }
|
191
|
-
expect(
|
190
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
|
192
191
|
:user => 'morty', :environment => { 'LC_ALL' => Chef::Config[:internal_locale] },
|
193
192
|
}).and_return(true)
|
194
|
-
|
193
|
+
shell_out_obj.shell_out(cmd, options)
|
195
194
|
end
|
196
195
|
end
|
197
196
|
end
|
198
197
|
|
199
198
|
describe "when the last argument is not a Hash" do
|
200
199
|
it "should add environment options and set environment['LC_ALL'] to 'en_US.UTF-8'" do
|
201
|
-
expect(
|
200
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, {
|
202
201
|
:environment => { 'LC_ALL' => Chef::Config[:internal_locale] },
|
203
202
|
}).and_return(true)
|
204
|
-
|
203
|
+
shell_out_obj.shell_out(cmd)
|
205
204
|
end
|
206
205
|
end
|
207
206
|
|
@@ -213,56 +212,56 @@ describe Chef::Mixin::ShellOut do
|
|
213
212
|
describe "and environment is an option" do
|
214
213
|
it "should not change environment['LC_ALL'] when set to nil" do
|
215
214
|
options = { :environment => { 'LC_ALL' => nil } }
|
216
|
-
expect(
|
217
|
-
|
215
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
216
|
+
shell_out_obj.shell_out_with_systems_locale(cmd, options)
|
218
217
|
end
|
219
218
|
|
220
219
|
it "should not change environment['LC_ALL'] when set to non-nil" do
|
221
220
|
options = { :environment => { 'LC_ALL' => 'en_US.UTF-8' } }
|
222
|
-
expect(
|
223
|
-
|
221
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
222
|
+
shell_out_obj.shell_out_with_systems_locale(cmd, options)
|
224
223
|
end
|
225
224
|
|
226
225
|
it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do
|
227
226
|
options = { :environment => { 'HOME' => '/Users/morty' } }
|
228
|
-
expect(
|
229
|
-
|
227
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
228
|
+
shell_out_obj.shell_out_with_systems_locale(cmd, options)
|
230
229
|
end
|
231
230
|
end
|
232
231
|
|
233
232
|
describe "and env is an option" do
|
234
233
|
it "should not change env when set to nil" do
|
235
234
|
options = { :env => { 'LC_ALL' => nil } }
|
236
|
-
expect(
|
237
|
-
|
235
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
236
|
+
shell_out_obj.shell_out_with_systems_locale(cmd, options)
|
238
237
|
end
|
239
238
|
|
240
239
|
it "should not change env when set to non-nil" do
|
241
240
|
options = { :env => { 'LC_ALL' => 'en_US.UTF-8'}}
|
242
|
-
expect(
|
243
|
-
|
241
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
242
|
+
shell_out_obj.shell_out_with_systems_locale(cmd, options)
|
244
243
|
end
|
245
244
|
|
246
245
|
it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do
|
247
246
|
options = { :env => { 'HOME' => '/Users/morty' } }
|
248
|
-
expect(
|
249
|
-
|
247
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
248
|
+
shell_out_obj.shell_out_with_systems_locale(cmd, options)
|
250
249
|
end
|
251
250
|
end
|
252
251
|
|
253
252
|
describe "and no env/environment option is present" do
|
254
253
|
it "should no longer add environment option and set environment['LC_ALL'] to nil" do
|
255
254
|
options = { :user => 'morty' }
|
256
|
-
expect(
|
257
|
-
|
255
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true)
|
256
|
+
shell_out_obj.shell_out_with_systems_locale(cmd, options)
|
258
257
|
end
|
259
258
|
end
|
260
259
|
end
|
261
260
|
|
262
261
|
describe "when the last argument is not a Hash" do
|
263
262
|
it "should no longer add environment options and set environment['LC_ALL'] to nil" do
|
264
|
-
expect(
|
265
|
-
|
263
|
+
expect(shell_out_obj).to receive(:shell_out_command).with(cmd).and_return(true)
|
264
|
+
shell_out_obj.shell_out_with_systems_locale(cmd)
|
266
265
|
end
|
267
266
|
end
|
268
267
|
end
|
data/spec/unit/node_spec.rb
CHANGED
@@ -1213,6 +1213,40 @@ describe Chef::Node do
|
|
1213
1213
|
node.save
|
1214
1214
|
end
|
1215
1215
|
|
1216
|
+
it "should save false-y whitelisted attributes" do
|
1217
|
+
Chef::Config[:default_attribute_whitelist] = [
|
1218
|
+
"foo/bar/baz"
|
1219
|
+
]
|
1220
|
+
|
1221
|
+
data = {
|
1222
|
+
"default" => {
|
1223
|
+
"foo" => {
|
1224
|
+
"bar" => {
|
1225
|
+
"baz" => false,
|
1226
|
+
},
|
1227
|
+
"other" => {
|
1228
|
+
"stuff" => true,
|
1229
|
+
}
|
1230
|
+
}
|
1231
|
+
}
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
selected_data = {
|
1235
|
+
"default" => {
|
1236
|
+
"foo" => {
|
1237
|
+
"bar" => {
|
1238
|
+
"baz" => false,
|
1239
|
+
}
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
node.name("falsey-monkey")
|
1245
|
+
allow(node).to receive(:for_json).and_return(data)
|
1246
|
+
expect(@rest).to receive(:put_rest).with("nodes/falsey-monkey", selected_data).and_return("foo")
|
1247
|
+
node.save
|
1248
|
+
end
|
1249
|
+
|
1216
1250
|
it "should not save any attributes if the whitelist is empty" do
|
1217
1251
|
Chef::Config[:automatic_attribute_whitelist] = []
|
1218
1252
|
|
@@ -38,8 +38,8 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
|
|
38
38
|
result
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
Chef::
|
41
|
+
def canonicalize(path)
|
42
|
+
Chef::Platform.windows? ? path.gsub('/', '\\') : path
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "when the target is a symlink" do
|
@@ -68,7 +68,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
|
|
68
68
|
expect(provider.current_resource.link_type).to eq(:symbolic)
|
69
69
|
end
|
70
70
|
it "should update the source of the existing link with the links target" do
|
71
|
-
expect(
|
71
|
+
expect(provider.current_resource.to).to eq(canonicalize("#{CHEF_SPEC_DATA}/fofile"))
|
72
72
|
end
|
73
73
|
it "should set the owner" do
|
74
74
|
expect(provider.current_resource.owner).to eq(501)
|
@@ -110,7 +110,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
|
|
110
110
|
expect(provider.current_resource.link_type).to eq(:symbolic)
|
111
111
|
end
|
112
112
|
it "should update the source of the existing link to the link's target" do
|
113
|
-
expect(
|
113
|
+
expect(provider.current_resource.to).to eq(canonicalize("#{CHEF_SPEC_DATA}/fofile"))
|
114
114
|
end
|
115
115
|
it "should not set the owner" do
|
116
116
|
expect(provider.current_resource.owner).to be_nil
|
@@ -221,7 +221,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do
|
|
221
221
|
expect(provider.current_resource.link_type).to eq(:hard)
|
222
222
|
end
|
223
223
|
it "should update the source of the existing link to the link's target" do
|
224
|
-
expect(
|
224
|
+
expect(provider.current_resource.to).to eq(canonicalize("#{CHEF_SPEC_DATA}/fofile"))
|
225
225
|
end
|
226
226
|
it "should not set the owner" do
|
227
227
|
expect(provider.current_resource.owner).to eq(nil)
|
@@ -20,46 +20,51 @@ require 'spec_helper'
|
|
20
20
|
require 'ostruct'
|
21
21
|
|
22
22
|
describe Chef::Provider::Package::Apt do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
23
|
+
# XXX: sorry this is ugly and was done quickly to get 12.0.2 out, this file needs a rewrite to use
|
24
|
+
# let blocks and shared examples
|
25
|
+
[ Chef::Resource::Package, Chef::Resource::AptPackage ].each do |resource_klass|
|
26
|
+
describe "when the new_resource is a #{resource_klass}" do
|
27
|
+
|
28
|
+
before(:each) do
|
29
|
+
@node = Chef::Node.new
|
30
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
31
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
32
|
+
@new_resource = resource_klass.new("irssi", @run_context)
|
33
|
+
|
34
|
+
@status = double("Status", :exitstatus => 0)
|
35
|
+
@provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context)
|
36
|
+
@stdin = StringIO.new
|
37
|
+
@stdout =<<-PKG_STATUS
|
33
38
|
irssi:
|
34
39
|
Installed: (none)
|
35
40
|
Candidate: 0.8.14-1ubuntu4
|
36
41
|
Version table:
|
37
42
|
0.8.14-1ubuntu4 0
|
38
43
|
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
|
39
|
-
PKG_STATUS
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
describe "when loading current resource" do
|
46
|
-
|
47
|
-
it "should create a current resource with the name of the new_resource" do
|
48
|
-
expect(@provider).to receive(:shell_out!).with(
|
49
|
-
"apt-cache policy #{@new_resource.package_name}",
|
50
|
-
:timeout => @timeout
|
51
|
-
).and_return(@shell_out)
|
52
|
-
@provider.load_current_resource
|
44
|
+
PKG_STATUS
|
45
|
+
@stderr = ""
|
46
|
+
@shell_out = OpenStruct.new(:stdout => @stdout,:stdin => @stdin,:stderr => @stderr,:status => @status,:exitstatus => 0)
|
47
|
+
@timeout = 900
|
48
|
+
end
|
53
49
|
|
54
|
-
|
55
|
-
expect(current_resource).to be_a(Chef::Resource::Package)
|
56
|
-
expect(current_resource.name).to eq("irssi")
|
57
|
-
expect(current_resource.package_name).to eq("irssi")
|
58
|
-
expect(current_resource.version).to be_nil
|
59
|
-
end
|
50
|
+
describe "when loading current resource" do
|
60
51
|
|
61
|
-
|
62
|
-
|
52
|
+
it "should create a current resource with the name of the new_resource" do
|
53
|
+
expect(@provider).to receive(:shell_out!).with(
|
54
|
+
"apt-cache policy #{@new_resource.package_name}",
|
55
|
+
:timeout => @timeout
|
56
|
+
).and_return(@shell_out)
|
57
|
+
@provider.load_current_resource
|
58
|
+
|
59
|
+
current_resource = @provider.current_resource
|
60
|
+
expect(current_resource).to be_a(Chef::Resource::Package)
|
61
|
+
expect(current_resource.name).to eq("irssi")
|
62
|
+
expect(current_resource.package_name).to eq("irssi")
|
63
|
+
expect(current_resource.version).to be_nil
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should set the installed version if package has one" do
|
67
|
+
@stdout.replace(<<-INSTALLED)
|
63
68
|
sudo:
|
64
69
|
Installed: 1.7.2p1-1ubuntu5.3
|
65
70
|
Candidate: 1.7.2p1-1ubuntu5.3
|
@@ -70,29 +75,29 @@ sudo:
|
|
70
75
|
100 /var/lib/dpkg/status
|
71
76
|
1.7.2p1-1ubuntu5 0
|
72
77
|
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
|
73
|
-
INSTALLED
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
78
|
+
INSTALLED
|
79
|
+
expect(@provider).to receive(:shell_out!).and_return(@shell_out)
|
80
|
+
@provider.load_current_resource
|
81
|
+
expect(@provider.current_resource.version).to eq("1.7.2p1-1ubuntu5.3")
|
82
|
+
expect(@provider.candidate_version).to eql("1.7.2p1-1ubuntu5.3")
|
83
|
+
end
|
84
|
+
|
85
|
+
# libmysqlclient-dev is a real package in newer versions of debian + ubuntu
|
86
|
+
# list of virtual packages: http://www.debian.org/doc/packaging-manuals/virtual-package-names-list.txt
|
87
|
+
it "should not install the virtual package there is a single provider package and it is installed" do
|
88
|
+
@new_resource.package_name("libmysqlclient15-dev")
|
89
|
+
virtual_package_out=<<-VPKG_STDOUT
|
85
90
|
libmysqlclient15-dev:
|
86
91
|
Installed: (none)
|
87
92
|
Candidate: (none)
|
88
93
|
Version table:
|
89
|
-
VPKG_STDOUT
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
94
|
+
VPKG_STDOUT
|
95
|
+
virtual_package = double(:stdout => virtual_package_out,:exitstatus => 0)
|
96
|
+
expect(@provider).to receive(:shell_out!).with(
|
97
|
+
"apt-cache policy libmysqlclient15-dev",
|
98
|
+
:timeout => @timeout
|
99
|
+
).and_return(virtual_package)
|
100
|
+
showpkg_out =<<-SHOWPKG_STDOUT
|
96
101
|
Package: libmysqlclient15-dev
|
97
102
|
Versions:
|
98
103
|
|
@@ -109,13 +114,13 @@ Reverse Provides:
|
|
109
114
|
libmysqlclient-dev 5.1.41-3ubuntu12.7
|
110
115
|
libmysqlclient-dev 5.1.41-3ubuntu12.10
|
111
116
|
libmysqlclient-dev 5.1.41-3ubuntu12
|
112
|
-
SHOWPKG_STDOUT
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
117
|
+
SHOWPKG_STDOUT
|
118
|
+
showpkg = double(:stdout => showpkg_out,:exitstatus => 0)
|
119
|
+
expect(@provider).to receive(:shell_out!).with(
|
120
|
+
"apt-cache showpkg libmysqlclient15-dev",
|
121
|
+
:timeout => @timeout
|
122
|
+
).and_return(showpkg)
|
123
|
+
real_package_out=<<-RPKG_STDOUT
|
119
124
|
libmysqlclient-dev:
|
120
125
|
Installed: 5.1.41-3ubuntu12.10
|
121
126
|
Candidate: 5.1.41-3ubuntu12.10
|
@@ -127,29 +132,29 @@ libmysqlclient-dev:
|
|
127
132
|
500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages
|
128
133
|
5.1.41-3ubuntu12 0
|
129
134
|
500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages
|
130
|
-
RPKG_STDOUT
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
RPKG_STDOUT
|
136
|
+
real_package = double(:stdout => real_package_out,:exitstatus => 0)
|
137
|
+
expect(@provider).to receive(:shell_out!).with(
|
138
|
+
"apt-cache policy libmysqlclient-dev",
|
139
|
+
:timeout => @timeout
|
140
|
+
).and_return(real_package)
|
141
|
+
@provider.load_current_resource
|
142
|
+
end
|
138
143
|
|
139
|
-
|
140
|
-
|
141
|
-
|
144
|
+
it "should raise an exception if you specify a virtual package with multiple provider packages" do
|
145
|
+
@new_resource.package_name("mp3-decoder")
|
146
|
+
virtual_package_out=<<-VPKG_STDOUT
|
142
147
|
mp3-decoder:
|
143
148
|
Installed: (none)
|
144
149
|
Candidate: (none)
|
145
150
|
Version table:
|
146
|
-
VPKG_STDOUT
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
151
|
+
VPKG_STDOUT
|
152
|
+
virtual_package = double(:stdout => virtual_package_out,:exitstatus => 0)
|
153
|
+
expect(@provider).to receive(:shell_out!).with(
|
154
|
+
"apt-cache policy mp3-decoder",
|
155
|
+
:timeout => @timeout
|
156
|
+
).and_return(virtual_package)
|
157
|
+
showpkg_out=<<-SHOWPKG_STDOUT
|
153
158
|
Package: mp3-decoder
|
154
159
|
Versions:
|
155
160
|
|
@@ -169,191 +174,193 @@ vlc 1.0.6-1ubuntu1
|
|
169
174
|
opencubicplayer 1:0.1.17-2
|
170
175
|
mpg321 0.2.10.6
|
171
176
|
mpg123 1.12.1-0ubuntu1
|
172
|
-
SHOWPKG_STDOUT
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
it "should run apt-cache policy with the default_release option, if there is one and provider is explicitly defined" do
|
182
|
-
@new_resource = Chef::Resource::AptPackage.new("irssi", @run_context)
|
183
|
-
@provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context)
|
184
|
-
|
185
|
-
allow(@new_resource).to receive(:default_release).and_return("lenny-backports")
|
186
|
-
allow(@new_resource).to receive(:provider).and_return("Chef::Provider::Package::Apt")
|
187
|
-
expect(@provider).to receive(:shell_out!).with(
|
188
|
-
"apt-cache -o APT::Default-Release=lenny-backports policy irssi",
|
189
|
-
:timeout => @timeout
|
190
|
-
).and_return(@shell_out)
|
191
|
-
@provider.load_current_resource
|
192
|
-
end
|
193
|
-
|
194
|
-
it "raises an exception if a source is specified (CHEF-5113)" do
|
195
|
-
@new_resource.source "pluto"
|
196
|
-
@provider.define_resource_requirements
|
197
|
-
expect(@provider).to receive(:shell_out!).with("apt-cache policy irssi", {:timeout=>900}).and_return(@shell_out)
|
198
|
-
expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
context "after loading the current resource" do
|
203
|
-
before do
|
204
|
-
@current_resource = Chef::Resource::Package.new("irssi", @run_context)
|
205
|
-
@provider.current_resource = @current_resource
|
206
|
-
end
|
207
|
-
|
208
|
-
describe "install_package" do
|
209
|
-
it "should run apt-get install with the package name and version" do
|
210
|
-
expect(@provider).to receive(:shell_out!). with(
|
211
|
-
"apt-get -q -y install irssi=0.8.12-7",
|
212
|
-
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
213
|
-
:timeout => @timeout
|
214
|
-
)
|
215
|
-
@provider.install_package("irssi", "0.8.12-7")
|
216
|
-
end
|
217
|
-
|
218
|
-
it "should run apt-get install with the package name and version and options if specified" do
|
219
|
-
expect(@provider).to receive(:shell_out!).with(
|
220
|
-
"apt-get -q -y --force-yes install irssi=0.8.12-7",
|
221
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
222
|
-
:timeout => @timeout
|
223
|
-
)
|
224
|
-
@new_resource.options("--force-yes")
|
225
|
-
@provider.install_package("irssi", "0.8.12-7")
|
226
|
-
end
|
227
|
-
|
228
|
-
it "should run apt-get install with the package name and version and default_release if there is one and provider is explicitly defined" do
|
229
|
-
@new_resource = nil
|
230
|
-
@new_resource = Chef::Resource::AptPackage.new("irssi", @run_context)
|
231
|
-
@new_resource.default_release("lenny-backports")
|
232
|
-
@new_resource.provider = @provider
|
233
|
-
@provider.new_resource = @new_resource
|
234
|
-
|
235
|
-
expect(@provider).to receive(:shell_out!).with(
|
236
|
-
"apt-get -q -y -o APT::Default-Release=lenny-backports install irssi=0.8.12-7",
|
237
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
238
|
-
:timeout => @timeout
|
239
|
-
)
|
240
|
-
|
241
|
-
@provider.install_package("irssi", "0.8.12-7")
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
describe Chef::Provider::Package::Apt, "upgrade_package" do
|
246
|
-
|
247
|
-
it "should run install_package with the name and version" do
|
248
|
-
expect(@provider).to receive(:install_package).with("irssi", "0.8.12-7")
|
249
|
-
@provider.upgrade_package("irssi", "0.8.12-7")
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
describe Chef::Provider::Package::Apt, "remove_package" do
|
254
|
-
|
255
|
-
it "should run apt-get remove with the package name" do
|
256
|
-
expect(@provider).to receive(:shell_out!).with(
|
257
|
-
"apt-get -q -y remove irssi",
|
258
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
259
|
-
:timeout => @timeout
|
260
|
-
)
|
261
|
-
@provider.remove_package("irssi", "0.8.12-7")
|
262
|
-
end
|
263
|
-
|
264
|
-
it "should run apt-get remove with the package name and options if specified" do
|
265
|
-
expect(@provider).to receive(:shell_out!).with(
|
266
|
-
"apt-get -q -y --force-yes remove irssi",
|
267
|
-
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
268
|
-
:timeout => @timeout
|
269
|
-
)
|
270
|
-
@new_resource.options("--force-yes")
|
271
|
-
|
272
|
-
@provider.remove_package("irssi", "0.8.12-7")
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
describe "when purging a package" do
|
277
|
-
|
278
|
-
it "should run apt-get purge with the package name" do
|
279
|
-
expect(@provider).to receive(:shell_out!).with(
|
280
|
-
"apt-get -q -y purge irssi",
|
281
|
-
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
282
|
-
:timeout => @timeout
|
283
|
-
)
|
284
|
-
@provider.purge_package("irssi", "0.8.12-7")
|
285
|
-
end
|
286
|
-
|
287
|
-
it "should run apt-get purge with the package name and options if specified" do
|
288
|
-
expect(@provider).to receive(:shell_out!).with(
|
289
|
-
"apt-get -q -y --force-yes purge irssi",
|
290
|
-
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
291
|
-
:timeout => @timeout
|
292
|
-
)
|
293
|
-
@new_resource.options("--force-yes")
|
294
|
-
|
295
|
-
@provider.purge_package("irssi", "0.8.12-7")
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
|
-
describe "when preseeding a package" do
|
300
|
-
before(:each) do
|
301
|
-
allow(@provider).to receive(:get_preseed_file).and_return("/tmp/irssi-0.8.12-7.seed")
|
302
|
-
end
|
303
|
-
|
304
|
-
it "should get the full path to the preseed response file" do
|
305
|
-
expect(@provider).to receive(:get_preseed_file).with("irssi", "0.8.12-7").and_return("/tmp/irssi-0.8.12-7.seed")
|
306
|
-
file = @provider.get_preseed_file("irssi", "0.8.12-7")
|
307
|
-
|
308
|
-
expect(@provider).to receive(:shell_out!).with(
|
309
|
-
"debconf-set-selections /tmp/irssi-0.8.12-7.seed",
|
310
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
311
|
-
:timeout => @timeout
|
312
|
-
)
|
313
|
-
|
314
|
-
@provider.preseed_package(file)
|
315
|
-
end
|
316
|
-
|
317
|
-
it "should run debconf-set-selections on the preseed file if it has changed" do
|
318
|
-
expect(@provider).to receive(:shell_out!).with(
|
319
|
-
"debconf-set-selections /tmp/irssi-0.8.12-7.seed",
|
320
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
321
|
-
:timeout => @timeout
|
322
|
-
)
|
323
|
-
file = @provider.get_preseed_file("irssi", "0.8.12-7")
|
324
|
-
@provider.preseed_package(file)
|
325
|
-
end
|
177
|
+
SHOWPKG_STDOUT
|
178
|
+
showpkg = double(:stdout => showpkg_out,:exitstatus => 0)
|
179
|
+
expect(@provider).to receive(:shell_out!).with(
|
180
|
+
"apt-cache showpkg mp3-decoder",
|
181
|
+
:timeout => @timeout
|
182
|
+
).and_return(showpkg)
|
183
|
+
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Package)
|
184
|
+
end
|
326
185
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
@new_resource.response_file "/tmp/file"
|
331
|
-
allow(@provider).to receive(:get_preseed_file).and_return(false)
|
332
|
-
expect(@provider).not_to receive(:shell_out!)
|
333
|
-
@provider.run_action(:reconfig)
|
334
|
-
end
|
335
|
-
end
|
186
|
+
it "should run apt-cache policy with the default_release option, if there is one on the resource" do
|
187
|
+
@new_resource = Chef::Resource::AptPackage.new("irssi", @run_context)
|
188
|
+
@provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context)
|
336
189
|
|
337
|
-
|
338
|
-
|
339
|
-
expect(@provider).to receive(:shell_out!).with(
|
340
|
-
"dpkg-reconfigure irssi",
|
341
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
342
|
-
:timeout => @timeout
|
343
|
-
)
|
344
|
-
@provider.reconfig_package("irssi", "0.8.12-7")
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
|
-
describe "when installing a virtual package" do
|
349
|
-
it "should install the package without specifying a version" do
|
350
|
-
@provider.is_virtual_package = true
|
190
|
+
allow(@new_resource).to receive(:default_release).and_return("lenny-backports")
|
191
|
+
allow(@new_resource).to receive(:provider).and_return(nil)
|
351
192
|
expect(@provider).to receive(:shell_out!).with(
|
352
|
-
"apt-
|
353
|
-
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
193
|
+
"apt-cache -o APT::Default-Release=lenny-backports policy irssi",
|
354
194
|
:timeout => @timeout
|
355
|
-
)
|
356
|
-
@provider.
|
195
|
+
).and_return(@shell_out)
|
196
|
+
@provider.load_current_resource
|
197
|
+
end
|
198
|
+
|
199
|
+
it "raises an exception if a source is specified (CHEF-5113)" do
|
200
|
+
@new_resource.source "pluto"
|
201
|
+
@provider.define_resource_requirements
|
202
|
+
expect(@provider).to receive(:shell_out!).with("apt-cache policy irssi", {:timeout=>900}).and_return(@shell_out)
|
203
|
+
expect { @provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context "after loading the current resource" do
|
208
|
+
before do
|
209
|
+
@current_resource = resource_klass.new("irssi", @run_context)
|
210
|
+
@provider.current_resource = @current_resource
|
211
|
+
end
|
212
|
+
|
213
|
+
describe "install_package" do
|
214
|
+
it "should run apt-get install with the package name and version" do
|
215
|
+
expect(@provider).to receive(:shell_out!). with(
|
216
|
+
"apt-get -q -y install irssi=0.8.12-7",
|
217
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
218
|
+
:timeout => @timeout
|
219
|
+
)
|
220
|
+
@provider.install_package("irssi", "0.8.12-7")
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should run apt-get install with the package name and version and options if specified" do
|
224
|
+
expect(@provider).to receive(:shell_out!).with(
|
225
|
+
"apt-get -q -y --force-yes install irssi=0.8.12-7",
|
226
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
227
|
+
:timeout => @timeout
|
228
|
+
)
|
229
|
+
@new_resource.options("--force-yes")
|
230
|
+
@provider.install_package("irssi", "0.8.12-7")
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should run apt-get install with the package name and version and default_release if there is one and provider is explicitly defined" do
|
234
|
+
@new_resource = nil
|
235
|
+
@new_resource = Chef::Resource::AptPackage.new("irssi", @run_context)
|
236
|
+
@new_resource.default_release("lenny-backports")
|
237
|
+
@new_resource.provider = nil
|
238
|
+
@provider.new_resource = @new_resource
|
239
|
+
|
240
|
+
expect(@provider).to receive(:shell_out!).with(
|
241
|
+
"apt-get -q -y -o APT::Default-Release=lenny-backports install irssi=0.8.12-7",
|
242
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
243
|
+
:timeout => @timeout
|
244
|
+
)
|
245
|
+
|
246
|
+
@provider.install_package("irssi", "0.8.12-7")
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
describe resource_klass, "upgrade_package" do
|
251
|
+
|
252
|
+
it "should run install_package with the name and version" do
|
253
|
+
expect(@provider).to receive(:install_package).with("irssi", "0.8.12-7")
|
254
|
+
@provider.upgrade_package("irssi", "0.8.12-7")
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
describe resource_klass, "remove_package" do
|
259
|
+
|
260
|
+
it "should run apt-get remove with the package name" do
|
261
|
+
expect(@provider).to receive(:shell_out!).with(
|
262
|
+
"apt-get -q -y remove irssi",
|
263
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
264
|
+
:timeout => @timeout
|
265
|
+
)
|
266
|
+
@provider.remove_package("irssi", "0.8.12-7")
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should run apt-get remove with the package name and options if specified" do
|
270
|
+
expect(@provider).to receive(:shell_out!).with(
|
271
|
+
"apt-get -q -y --force-yes remove irssi",
|
272
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
273
|
+
:timeout => @timeout
|
274
|
+
)
|
275
|
+
@new_resource.options("--force-yes")
|
276
|
+
|
277
|
+
@provider.remove_package("irssi", "0.8.12-7")
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe "when purging a package" do
|
282
|
+
|
283
|
+
it "should run apt-get purge with the package name" do
|
284
|
+
expect(@provider).to receive(:shell_out!).with(
|
285
|
+
"apt-get -q -y purge irssi",
|
286
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
287
|
+
:timeout => @timeout
|
288
|
+
)
|
289
|
+
@provider.purge_package("irssi", "0.8.12-7")
|
290
|
+
end
|
291
|
+
|
292
|
+
it "should run apt-get purge with the package name and options if specified" do
|
293
|
+
expect(@provider).to receive(:shell_out!).with(
|
294
|
+
"apt-get -q -y --force-yes purge irssi",
|
295
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
296
|
+
:timeout => @timeout
|
297
|
+
)
|
298
|
+
@new_resource.options("--force-yes")
|
299
|
+
|
300
|
+
@provider.purge_package("irssi", "0.8.12-7")
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
describe "when preseeding a package" do
|
305
|
+
before(:each) do
|
306
|
+
allow(@provider).to receive(:get_preseed_file).and_return("/tmp/irssi-0.8.12-7.seed")
|
307
|
+
end
|
308
|
+
|
309
|
+
it "should get the full path to the preseed response file" do
|
310
|
+
expect(@provider).to receive(:get_preseed_file).with("irssi", "0.8.12-7").and_return("/tmp/irssi-0.8.12-7.seed")
|
311
|
+
file = @provider.get_preseed_file("irssi", "0.8.12-7")
|
312
|
+
|
313
|
+
expect(@provider).to receive(:shell_out!).with(
|
314
|
+
"debconf-set-selections /tmp/irssi-0.8.12-7.seed",
|
315
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
316
|
+
:timeout => @timeout
|
317
|
+
)
|
318
|
+
|
319
|
+
@provider.preseed_package(file)
|
320
|
+
end
|
321
|
+
|
322
|
+
it "should run debconf-set-selections on the preseed file if it has changed" do
|
323
|
+
expect(@provider).to receive(:shell_out!).with(
|
324
|
+
"debconf-set-selections /tmp/irssi-0.8.12-7.seed",
|
325
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil},
|
326
|
+
:timeout => @timeout
|
327
|
+
)
|
328
|
+
file = @provider.get_preseed_file("irssi", "0.8.12-7")
|
329
|
+
@provider.preseed_package(file)
|
330
|
+
end
|
331
|
+
|
332
|
+
it "should not run debconf-set-selections if the preseed file has not changed" do
|
333
|
+
allow(@provider).to receive(:check_package_state)
|
334
|
+
@current_resource.version "0.8.11"
|
335
|
+
@new_resource.response_file "/tmp/file"
|
336
|
+
allow(@provider).to receive(:get_preseed_file).and_return(false)
|
337
|
+
expect(@provider).not_to receive(:shell_out!)
|
338
|
+
@provider.run_action(:reconfig)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
describe "when reconfiguring a package" do
|
343
|
+
it "should run dpkg-reconfigure package" do
|
344
|
+
expect(@provider).to receive(:shell_out!).with(
|
345
|
+
"dpkg-reconfigure irssi",
|
346
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
347
|
+
:timeout => @timeout
|
348
|
+
)
|
349
|
+
@provider.reconfig_package("irssi", "0.8.12-7")
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
describe "when installing a virtual package" do
|
354
|
+
it "should install the package without specifying a version" do
|
355
|
+
@provider.is_virtual_package = true
|
356
|
+
expect(@provider).to receive(:shell_out!).with(
|
357
|
+
"apt-get -q -y install libmysqlclient-dev",
|
358
|
+
:env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil },
|
359
|
+
:timeout => @timeout
|
360
|
+
)
|
361
|
+
@provider.install_package("libmysqlclient-dev", "not_a_real_version")
|
362
|
+
end
|
363
|
+
end
|
357
364
|
end
|
358
365
|
end
|
359
366
|
end
|