minitest-chef-handler 0.6.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -1
- data/.travis.yml +4 -0
- data/Appraisals +7 -0
- data/Berksfile +4 -0
- data/Gemfile +3 -0
- data/History.txt +6 -0
- data/README.md +23 -17
- data/Rakefile +7 -3
- data/Vagrantfile +17 -4
- data/examples/spec_examples/files/default/tests/minitest/{example_test.rb → default_test.rb} +15 -21
- data/examples/spec_examples/metadata.rb +1 -0
- data/gemfiles/chef_10.gemfile +8 -0
- data/gemfiles/chef_11.gemfile +8 -0
- data/lib/minitest-chef-handler/assertions.rb +41 -0
- data/lib/minitest-chef-handler/ci_runner.rb +1 -0
- data/lib/minitest-chef-handler/resources.rb +10 -4
- data/minitest-chef-handler.gemspec +8 -3
- data/spec/minitest-chef-handler/assertions_spec.rb +158 -4
- data/spec/minitest-chef-handler/resources_spec.rb +25 -4
- data/spec/spec_helper.rb +7 -3
- metadata +95 -23
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/README.md +0 -115
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/attributes/default.rb +0 -21
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/files/default/handlers/README +0 -1
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/metadata.json +0 -29
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/metadata.rb +0 -6
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/providers/default.rb +0 -83
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/recipes/default.rb +0 -31
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/recipes/json_file.rb +0 -28
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/recipes/minitest.rb +0 -24
- data/examples/chef-handler-cookbook/cookbooks/chef_handler/resources/default.rb +0 -34
- data/examples/simple-solo/cookbooks/foo/recipes/default.rb +0 -1
- data/examples/simple-solo/cookbooks/foo/test/test_foo.rb +0 -9
- data/examples/simple-solo/dna.json +0 -3
- data/examples/simple-solo/solo.rb +0 -10
- data/examples/simple-solo/spec/foo_spec.rb +0 -9
- data/examples/simple-solo/test/test_foo.rb +0 -9
- data/gemfile_chef_10 +0 -3
- data/gemfile_chef_11 +0 -4
- data/script/bootstrap +0 -11
- data/script/test +0 -28
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Appraisals
ADDED
data/Berksfile
ADDED
data/Gemfile
ADDED
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -2,15 +2,17 @@
|
|
2
2
|
|
3
3
|
Run minitest suites after your Chef recipes to check the status of your system.
|
4
4
|
|
5
|
+
[](https://travis-ci.org/calavera/minitest-chef-handler)
|
6
|
+
|
5
7
|
# Installation
|
6
8
|
|
7
|
-
```
|
8
|
-
|
9
|
+
```Bash
|
10
|
+
gem install minitest-chef-handler
|
9
11
|
```
|
10
12
|
|
11
13
|
## Usage
|
12
14
|
|
13
|
-
Add the report handler to your client.rb or solo.rb file:
|
15
|
+
Option 1: Add the report handler to your client.rb or solo.rb file:
|
14
16
|
|
15
17
|
```ruby
|
16
18
|
require 'minitest-chef-handler'
|
@@ -18,6 +20,15 @@ require 'minitest-chef-handler'
|
|
18
20
|
report_handlers << MiniTest::Chef::Handler.new
|
19
21
|
```
|
20
22
|
|
23
|
+
Options 2: Using [minitest-handler](https://github.com/btm/minitest-handler-cookbook)
|
24
|
+
```Ruby
|
25
|
+
# Vagrantfile
|
26
|
+
chef.run_list = [
|
27
|
+
"your-recipes",
|
28
|
+
"minitest-handler"
|
29
|
+
]
|
30
|
+
```
|
31
|
+
|
21
32
|
### Test cases
|
22
33
|
|
23
34
|
Write your tests as normal MiniTest cases extending from MiniTest::Chef::TestCase:
|
@@ -87,7 +98,12 @@ can also make assertions like these:
|
|
87
98
|
file("/etc/fstab").must_have(:mode, "644")
|
88
99
|
package("less").must_be_installed
|
89
100
|
service("chef-client").must_be_running
|
101
|
+
assert_directory "/etc", "root", "root", "755"
|
102
|
+
assert_file "/etc/fstab", "root", "root", "644"
|
103
|
+
assert_sh "ls /etc"
|
104
|
+
assert_logrotate "/etc/logrotate.d/mysql"
|
90
105
|
```
|
106
|
+
and [many more](lib/minitest-chef-handler/assertions.rb)
|
91
107
|
|
92
108
|
The resources supported are: `cron`, `directory`, `file`, `group`, `ifconfig`,
|
93
109
|
`link`, `mount`, `package`, `service` and `user`.
|
@@ -156,20 +172,10 @@ The instructions above have described how to use it in a Chef solo installation.
|
|
156
172
|
|
157
173
|
## Development
|
158
174
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
1. Load both versions of Chef dependencies:
|
164
|
-
|
165
|
-
```
|
166
|
-
$ script/bootstrap
|
167
|
-
```
|
168
|
-
|
169
|
-
2. Run unit and integration tests agains both versions of Chef:
|
170
|
-
|
171
|
-
```
|
172
|
-
$ script/test
|
175
|
+
```Ruby
|
176
|
+
bundle
|
177
|
+
bundle exec rake # unit tests
|
178
|
+
bundle exec vagrant up # integration tests (install virtualbox first and vagrant destroy -f afterwards to clean up)
|
173
179
|
```
|
174
180
|
|
175
181
|
## Copyright
|
data/Rakefile
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
|
1
|
+
require "bundler/setup"
|
2
2
|
require "bundler/gem_tasks"
|
3
3
|
require "rake/testtask"
|
4
|
+
require "appraisal"
|
4
5
|
|
5
|
-
Rake::TestTask.new do |t|
|
6
|
-
t.name = 'spec'
|
6
|
+
Rake::TestTask.new(:spec) do |t|
|
7
7
|
t.pattern = 'spec/**/*_spec.rb'
|
8
8
|
end
|
9
|
+
|
10
|
+
task :default do
|
11
|
+
sh "rake appraisal:install && rake appraisal spec"
|
12
|
+
end
|
data/Vagrantfile
CHANGED
@@ -1,8 +1,21 @@
|
|
1
|
+
require "berkshelf/vagrant"
|
2
|
+
|
3
|
+
unless ARGV[0] == "destroy"
|
4
|
+
# use current files, not the released gem from rubygems
|
5
|
+
result = `rake build`
|
6
|
+
raise "BUILD FAILED: #{result}" unless $?.success?
|
7
|
+
package = result[%r{pkg/.*}].sub(/\.$/,"")
|
8
|
+
end
|
9
|
+
|
1
10
|
Vagrant::Config.run do |config|
|
2
|
-
config.vm.box = "
|
11
|
+
config.vm.box = "precise64"
|
12
|
+
config.vm.provision :shell, :inline => "gem install /vagrant/#{package} --no-rdoc --no-ri"
|
3
13
|
config.vm.provision :chef_solo do |chef|
|
4
|
-
chef.
|
5
|
-
chef.
|
6
|
-
chef.
|
14
|
+
#chef.log_level = :debug
|
15
|
+
#chef.json = {"minitest" => {"verbose" => true}}
|
16
|
+
chef.run_list = [
|
17
|
+
"recipe[spec_examples]",
|
18
|
+
"minitest-handler",
|
19
|
+
]
|
7
20
|
end
|
8
21
|
end
|
data/examples/spec_examples/files/default/tests/minitest/{example_test.rb → default_test.rb}
RENAMED
@@ -6,15 +6,7 @@ require 'minitest/spec'
|
|
6
6
|
# Copyright 2012, Opscode, Inc.
|
7
7
|
#
|
8
8
|
describe_recipe 'spec_examples::default' do
|
9
|
-
|
10
|
-
# It's often convenient to load these includes in a separate helper along with
|
11
|
-
# your own helper methods, but here we just include them directly:
|
12
|
-
include MiniTest::Chef::Assertions
|
13
|
-
include MiniTest::Chef::Context
|
14
|
-
include MiniTest::Chef::Resources
|
15
|
-
|
16
9
|
describe "files" do
|
17
|
-
|
18
10
|
# = Testing that a file exists =
|
19
11
|
#
|
20
12
|
# The simplest assertion is that a file exists following the Chef run:
|
@@ -61,6 +53,7 @@ describe_recipe 'spec_examples::default' do
|
|
61
53
|
# You don't want to get too carried away doing this but it can be useful.
|
62
54
|
it "only root can modify the config file" do
|
63
55
|
file("/etc/fstab").must_have(:mode, "644").with(:owner, "root").and(:group, "root")
|
56
|
+
assert_file "/etc/fstab", "root", "root", 0644
|
64
57
|
end
|
65
58
|
|
66
59
|
# Alternatively you could express it like this so each assertion is nicely
|
@@ -98,19 +91,21 @@ describe_recipe 'spec_examples::default' do
|
|
98
91
|
|
99
92
|
# The file existence and permissions matchers are also valid for
|
100
93
|
# directories:
|
101
|
-
it
|
94
|
+
it "creates directories" do
|
95
|
+
directory("/etc/").must_exist.with(:owner, "root")
|
96
|
+
assert_directory "/etc", "root", "root", 0755
|
97
|
+
end
|
102
98
|
|
103
99
|
# = Links =
|
104
100
|
|
105
101
|
it "symlinks the foo in" do
|
106
102
|
link("/tmp/foo-symbolic").must_exist.with(
|
107
103
|
:link_type, :symbolic).and(:to, "/tmp/foo")
|
104
|
+
assert_symlinked_file "/tmp/foo-symbolic", "root", "root", 0600
|
108
105
|
end
|
109
|
-
|
110
106
|
end
|
111
107
|
|
112
108
|
describe "packages" do
|
113
|
-
|
114
109
|
# = Checking for package install =
|
115
110
|
it "installs my favorite pager" do
|
116
111
|
package("less").must_be_installed
|
@@ -136,26 +131,23 @@ describe_recipe 'spec_examples::default' do
|
|
136
131
|
|
137
132
|
# = Package versions =
|
138
133
|
it "installs the package with the right version" do
|
139
|
-
package("less").must_be_installed.with(:version, "
|
134
|
+
package("less").must_be_installed.with(:version, "444-1ubuntu1")
|
140
135
|
end
|
141
136
|
end
|
142
137
|
|
143
138
|
describe "services" do
|
144
|
-
|
145
139
|
# You can assert that a service must be running following the converge:
|
146
140
|
it "runs as a daemon" do
|
147
|
-
service("
|
141
|
+
service("ntp").must_be_running
|
148
142
|
end
|
149
143
|
|
150
144
|
# And that it will start when the server boots:
|
151
145
|
it "boots on startup" do
|
152
|
-
service("
|
146
|
+
service("ntp").must_be_enabled
|
153
147
|
end
|
154
|
-
|
155
148
|
end
|
156
149
|
|
157
150
|
describe "users and groups" do
|
158
|
-
|
159
151
|
# = Users =
|
160
152
|
|
161
153
|
# Check if a user has been created:
|
@@ -198,7 +190,6 @@ describe_recipe 'spec_examples::default' do
|
|
198
190
|
end
|
199
191
|
|
200
192
|
describe "cron entries" do
|
201
|
-
|
202
193
|
it "creates a crontab entry" do
|
203
194
|
cron("noop").must_exist.with(:hour, "5").and(:minute, "0").and(:day, "*")
|
204
195
|
end
|
@@ -206,7 +197,6 @@ describe_recipe 'spec_examples::default' do
|
|
206
197
|
it "removes the self-destruct countdown" do
|
207
198
|
cron("self-destruct").wont_exist
|
208
199
|
end
|
209
|
-
|
210
200
|
end
|
211
201
|
|
212
202
|
# Note that the syntax for testing the mount resource is slightly different.
|
@@ -218,7 +208,6 @@ describe_recipe 'spec_examples::default' do
|
|
218
208
|
end
|
219
209
|
|
220
210
|
describe "networking" do
|
221
|
-
|
222
211
|
# = Test network interface settings =
|
223
212
|
describe "ifconfig" do
|
224
213
|
it "has the expected network interfaces configured" do
|
@@ -226,7 +215,12 @@ describe_recipe 'spec_examples::default' do
|
|
226
215
|
ifconfig(node['ipaddress'], :device => "eth1").wont_exist
|
227
216
|
end
|
228
217
|
end
|
229
|
-
|
230
218
|
end
|
231
219
|
|
220
|
+
describe "misc" do
|
221
|
+
it "can run assert_sh" do
|
222
|
+
result = assert_sh("ls /vagrant")
|
223
|
+
assert_includes result, "Gemfile"
|
224
|
+
end
|
225
|
+
end
|
232
226
|
end
|
@@ -124,6 +124,47 @@ module MiniTest
|
|
124
124
|
service
|
125
125
|
end
|
126
126
|
|
127
|
+
def assert_directory(dir, *args)
|
128
|
+
assert File.directory?(dir), "Expected #{dir} is be a directory"
|
129
|
+
assert_acl(dir, *args)
|
130
|
+
end
|
131
|
+
|
132
|
+
def assert_file(file, *args)
|
133
|
+
assert File.file?(file), "Expected #{file} is be a file"
|
134
|
+
assert_acl(file, *args)
|
135
|
+
end
|
136
|
+
|
137
|
+
def assert_acl(file, owner, group, mode)
|
138
|
+
file(file).
|
139
|
+
must_have(:owner, owner).
|
140
|
+
must_have(:group, group).
|
141
|
+
must_have(:mode, mode)
|
142
|
+
end
|
143
|
+
|
144
|
+
def assert_symlinked_file(file, *args)
|
145
|
+
assert File.symlink?(file), "Expected #{file} to be a symlink"
|
146
|
+
assert File.read(file, 1), "Expected #{file} to be linked to an existing file"
|
147
|
+
assert_acl file, *args
|
148
|
+
end
|
149
|
+
|
150
|
+
def assert_symlinked_directory(directory, *args)
|
151
|
+
assert File.symlink?(directory), "Expected #{directory} to be a symlink"
|
152
|
+
assert_sh "ls #{directory}/", "Expected #{directory} to link to an existing directory"
|
153
|
+
assert_acl directory, *args
|
154
|
+
end
|
155
|
+
|
156
|
+
def assert_logrotate(file)
|
157
|
+
assert_file file, "root", "root", 0644
|
158
|
+
assert_sh "logrotate -d #{file}", "Expected #{file} to pass logrotate validation"
|
159
|
+
end
|
160
|
+
|
161
|
+
def assert_sh(command, text=nil)
|
162
|
+
text ||= "Expected #{command} to succeed"
|
163
|
+
out = `#{command} 2>&1`
|
164
|
+
assert $?.success?, "#{text}, but failed with: #{out}"
|
165
|
+
out
|
166
|
+
end
|
167
|
+
|
127
168
|
end
|
128
169
|
end
|
129
170
|
end
|
@@ -35,11 +35,17 @@ module MiniTest
|
|
35
35
|
register_resource(:mount, :device)
|
36
36
|
|
37
37
|
::Chef::Resource.class_eval do
|
38
|
-
def with(attribute, values)
|
38
|
+
def with(attribute, values, failure_message=nil)
|
39
39
|
mt = Object.extend(MiniTest::Assertions)
|
40
40
|
actual_values = resource_value(attribute)
|
41
|
-
|
42
|
-
|
41
|
+
details = " #{path}" if respond_to?(:path)
|
42
|
+
|
43
|
+
failure_message ||= "The #{resource_name}#{details} does not have the expected #{attribute}"
|
44
|
+
if attribute == :mode
|
45
|
+
values = values.to_s(8) if values.is_a?(Integer) # better diff since 0755 would be shown as 493
|
46
|
+
values = values.to_s.sub(/^0+/, "") # better diff, ignore leading zeros
|
47
|
+
end
|
48
|
+
mt.assert_equal values, actual_values, failure_message
|
43
49
|
self
|
44
50
|
end
|
45
51
|
|
@@ -52,7 +58,7 @@ module MiniTest
|
|
52
58
|
case attribute
|
53
59
|
when :mode
|
54
60
|
return nil unless mode
|
55
|
-
mode.kind_of?(Integer) ? mode.to_s(8) : mode.to_s
|
61
|
+
mode.kind_of?(Integer) ? mode.to_s(8) : mode.to_s.sub(/^0+/, "")
|
56
62
|
when :owner || :user
|
57
63
|
return nil unless owner
|
58
64
|
owner.is_a?(Integer) ? Etc.getpwuid(owner).name : Etc.getpwnam(owner).name
|
@@ -11,11 +11,16 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
12
|
gem.name = "minitest-chef-handler"
|
13
13
|
gem.require_paths = ["lib"]
|
14
|
-
gem.version = '0.
|
14
|
+
gem.version = '1.0.0'
|
15
15
|
|
16
16
|
gem.add_dependency('minitest')
|
17
17
|
gem.add_dependency('chef')
|
18
18
|
gem.add_dependency('ci_reporter')
|
19
|
-
gem.add_development_dependency
|
20
|
-
gem.add_development_dependency
|
19
|
+
gem.add_development_dependency "rake"
|
20
|
+
gem.add_development_dependency "mocha"
|
21
|
+
gem.add_development_dependency "appraisal"
|
22
|
+
gem.add_development_dependency "ffi", ">= 1"
|
23
|
+
gem.add_development_dependency "vagrant", ">= 1.1"
|
24
|
+
gem.add_development_dependency "berkshelf", ">= 1.3.1"
|
25
|
+
gem.add_development_dependency "berkshelf-vagrant"
|
21
26
|
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
require "minitest-chef-handler/resources"
|
2
3
|
|
3
4
|
describe MiniTest::Chef::Assertions do
|
4
|
-
|
5
5
|
include MiniTest::Chef::Assertions
|
6
6
|
|
7
|
+
before do
|
8
|
+
Etc.stubs(:getpwnam).returns stub(:name => "me")
|
9
|
+
Etc.stubs(:getgrnam).returns stub(:name => "family")
|
10
|
+
end
|
11
|
+
|
7
12
|
def resource_for(hash)
|
8
13
|
Class.new do
|
9
14
|
hash.each_pair do |key,value|
|
@@ -12,16 +17,38 @@ describe MiniTest::Chef::Assertions do
|
|
12
17
|
end.new
|
13
18
|
end
|
14
19
|
|
20
|
+
def file(path)
|
21
|
+
file = ::Chef::Resource::File.new(path)
|
22
|
+
def file.mode; 0755;end
|
23
|
+
def file.owner; "xxx";end
|
24
|
+
def file.group; "xxx";end
|
25
|
+
file
|
26
|
+
end
|
27
|
+
|
15
28
|
module MiniTest::Chef::Assertions
|
16
29
|
class File
|
17
|
-
def self.read(path)
|
18
|
-
'# Generated by Chef'
|
30
|
+
def self.read(path, to=-1)
|
31
|
+
'# Generated by Chef'[0..to]
|
19
32
|
end
|
33
|
+
|
20
34
|
def self.mtime(path)
|
21
35
|
Time.now.utc
|
22
36
|
end
|
37
|
+
|
23
38
|
def self.exists?(path)
|
24
|
-
|
39
|
+
["/etc", "/etc/foo", "/etc/baz", "/etc/gar"].include?(path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.directory?(path)
|
43
|
+
['/etc', '/etc/gar'].include?(path)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.file?(path)
|
47
|
+
['/etc/foo'].include?(path)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.symlink?(path)
|
51
|
+
['/etc/baz', '/etc/gar'].include?(path)
|
25
52
|
end
|
26
53
|
end
|
27
54
|
end
|
@@ -290,4 +317,131 @@ describe MiniTest::Chef::Assertions do
|
|
290
317
|
end
|
291
318
|
end
|
292
319
|
|
320
|
+
describe "#assert_acl" do
|
321
|
+
it "does not blow up if everything is correct" do
|
322
|
+
assert_acl("/etc", "me", "family", 0755)
|
323
|
+
end
|
324
|
+
|
325
|
+
it "verifies that it has the correct owner" do
|
326
|
+
assert_triggered "The file /etc does not have the expected owner.\nExpected: \"foo\"\n Actual: \"me\"" do
|
327
|
+
assert_acl("/etc", "foo", "bar", 0755)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
it "verifies that it has the correct group" do
|
332
|
+
assert_triggered "The file /etc does not have the expected group.\nExpected: \"bar\"\n Actual: \"family\"" do
|
333
|
+
assert_acl("/etc", "me", "bar", 0755)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
it "verifies that it has the correct mode" do
|
338
|
+
assert_triggered "The file /etc does not have the expected mode.\nExpected: \"750\"\n Actual: \"755\"" do
|
339
|
+
assert_acl("/etc", "me", "family", 0750)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
describe "#assert_directory" do
|
345
|
+
it "does not blow up if everything is correct" do
|
346
|
+
assert_directory("/etc", "me", "family", 0755)
|
347
|
+
end
|
348
|
+
|
349
|
+
it "verifies that it is a directory" do
|
350
|
+
assert_triggered "Expected /etc/foo is be a directory" do
|
351
|
+
assert_directory("/etc/foo", "foo", "bar", 0755)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
it "verifies that it has the correct acl" do
|
356
|
+
assert_triggered "The file /etc does not have the expected owner.\nExpected: \"foo\"\n Actual: \"me\"" do
|
357
|
+
assert_directory("/etc", "foo", "bar", 0755)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
describe "#assert_file" do
|
363
|
+
it "does not blow up if everything is correct" do
|
364
|
+
assert_file("/etc/foo", "me", "family", 0755)
|
365
|
+
end
|
366
|
+
|
367
|
+
it "verifies that it is a file" do
|
368
|
+
assert_triggered "Expected /etc is be a file" do
|
369
|
+
assert_file("/etc", "foo", "bar", 0755)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
it "verifies that it has the correct acl" do
|
374
|
+
assert_triggered "The file /etc/foo does not have the expected owner.\nExpected: \"foo\"\n Actual: \"me\"" do
|
375
|
+
assert_file("/etc/foo", "foo", "bar", 0755)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
describe "#assert_symlinked_file" do
|
381
|
+
it "does not blow up if everything is correct" do
|
382
|
+
assert_symlinked_file("/etc/baz", "me", "family", 0755)
|
383
|
+
end
|
384
|
+
|
385
|
+
it "verifies that it is a symlink" do
|
386
|
+
assert_triggered "Expected /etc/foo to be a symlink" do
|
387
|
+
assert_symlinked_file("/etc/foo", "foo", "bar", 0755)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
it "verifies that it has the correct acl" do
|
392
|
+
assert_triggered "The file /etc/baz does not have the expected owner.\nExpected: \"foo\"\n Actual: \"me\"" do
|
393
|
+
assert_symlinked_file("/etc/baz", "foo", "bar", 0755)
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
describe "#assert_symlinked_directory" do
|
399
|
+
def assert_sh(*args)
|
400
|
+
end
|
401
|
+
|
402
|
+
it "does not blow up if everything is correct" do
|
403
|
+
assert_symlinked_directory("/etc/gar", "me", "family", 0755)
|
404
|
+
end
|
405
|
+
|
406
|
+
it "verifies that it is a symlink" do
|
407
|
+
assert_triggered "Expected /etc/foo to be a symlink" do
|
408
|
+
assert_symlinked_directory("/etc/foo", "foo", "bar", 0755)
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
it "verifies that it has the correct acl" do
|
413
|
+
assert_triggered "The file /etc/gar does not have the expected owner.\nExpected: \"foo\"\n Actual: \"me\"" do
|
414
|
+
assert_symlinked_directory("/etc/gar", "foo", "bar", 0755)
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
describe "#assert_logrotate" do
|
420
|
+
def assert_sh(*args)
|
421
|
+
end
|
422
|
+
|
423
|
+
def file(path)
|
424
|
+
file = super
|
425
|
+
def file.mode; 0644;end
|
426
|
+
file
|
427
|
+
end
|
428
|
+
|
429
|
+
it "does not blow up if everything is correct" do
|
430
|
+
Etc.stubs(:getpwnam).returns stub(:name => "root")
|
431
|
+
Etc.stubs(:getgrnam).returns stub(:name => "root")
|
432
|
+
assert_logrotate("/etc/foo")
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
describe "#assert_sh" do
|
437
|
+
it "does not blow up if everything is correct" do
|
438
|
+
assert_sh("true")
|
439
|
+
end
|
440
|
+
|
441
|
+
it "fails when command fails" do
|
442
|
+
assert_triggered "Expected echo ABC && false to succeed, but failed with: ABC" do
|
443
|
+
assert_sh("echo ABC && false")
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
293
447
|
end
|