diff options
| author | Markus Roberts <Markus@reality.com> | 2010-07-09 18:05:04 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-07-09 18:05:04 -0700 |
| commit | 9ee56f2e67be973da49b1d3f21de1bf87de35e6f (patch) | |
| tree | ddab8c01509f47664c52c8a6b165bb5a974f138f /test/ral | |
| parent | 051bd98751d9d4bc97f93f66723d9b7a00c0cfb4 (diff) | |
Code smell: Inconsistent indentation and related formatting issues
* Replaced 163 occurances of
defined\? +([@a-zA-Z_.0-9?=]+)
with
defined?(\1)
This makes detecting subsequent patterns easier.
3 Examples:
The code:
if ! defined? @parse_config
becomes:
if ! defined?(@parse_config)
The code:
return @option_parser if defined? @option_parser
becomes:
return @option_parser if defined?(@option_parser)
The code:
if defined? @local and @local
becomes:
if defined?(@local) and @local
* Eliminate trailing spaces.
Replaced 428 occurances of ^(.*?) +$ with \1
1 file was skipped.
test/ral/providers/host/parsed.rb because 0
* Replace leading tabs with an appropriate number of spaces.
Replaced 306 occurances of ^(\t+)(.*) with
Tabs are not consistently expanded in all environments.
* Don't arbitrarily wrap on sprintf (%) operator.
Replaced 143 occurances of
(.*['"] *%)
+(.*)
with
Splitting the line does nothing to aid clarity and hinders further refactorings.
3 Examples:
The code:
raise Puppet::Error, "Cannot create %s: basedir %s is a file" %
[dir, File.join(path)]
becomes:
raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)]
The code:
Puppet.err "Will not start without authorization file %s" %
Puppet[:authconfig]
becomes:
Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig]
The code:
$stderr.puts "Could not find host for PID %s with status %s" %
[pid, $?.exitstatus]
becomes:
$stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus]
* Don't break short arrays/parameter list in two.
Replaced 228 occurances of
(.*)
+(.*)
with
3 Examples:
The code:
puts @format.wrap(type.provider(prov).doc,
:indent => 4, :scrub => true)
becomes:
puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true)
The code:
assert(FileTest.exists?(daily),
"Did not make daily graph for %s" % type)
becomes:
assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type)
The code:
assert(prov.target_object(:first).read !~ /^notdisk/,
"Did not remove thing from disk")
becomes:
assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk")
* If arguments must wrap, treat them all equally
Replaced 510 occurances of
lines ending in things like ...(foo, or ...(bar(1,3),
with
\1
\2
3 Examples:
The code:
midscope.to_hash(false),
becomes:
assert_equal(
The code:
botscope.to_hash(true),
becomes:
# bottomscope, then checking that we see the right stuff.
The code:
:path => link,
becomes:
* Replaced 4516 occurances of ^( *)(.*) with
The present code base is supposed to use four-space indentation. In some places we failed
to maintain that standard. These should be fixed regardless of the 2 vs. 4 space question.
15 Examples:
The code:
def run_comp(cmd)
puts cmd
results = []
old_sync = $stdout.sync
$stdout.sync = true
line = []
begin
open("| #{cmd}", "r") do |f|
until f.eof? do
c = f.getc
becomes:
def run_comp(cmd)
puts cmd
results = []
old_sync = $stdout.sync
$stdout.sync = true
line = []
begin
open("| #{cmd}", "r") do |f|
until f.eof? do
c = f.getc
The code:
s.gsub!(/.{4}/n, '\\\\u\&')
}
string.force_encoding(Encoding::UTF_8)
string
rescue Iconv::Failure => e
raise GeneratorError, "Caught #{e.class}: #{e}"
end
else
def utf8_to_pson(string) # :nodoc:
string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] }
string.gsub!(/(
becomes:
s.gsub!(/.{4}/n, '\\\\u\&')
}
string.force_encoding(Encoding::UTF_8)
string
rescue Iconv::Failure => e
raise GeneratorError, "Caught #{e.class}: #{e}"
end
else
def utf8_to_pson(string) # :nodoc:
string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] }
string.gsub!(/(
The code:
end
}
rvalues: rvalue
| rvalues comma rvalue {
if val[0].instance_of?(AST::ASTArray)
result = val[0].push(val[2])
else
result = ast AST::ASTArray, :children => [val[0],val[2]]
end
}
becomes:
end
}
rvalues: rvalue
| rvalues comma rvalue {
if val[0].instance_of?(AST::ASTArray)
result = val[0].push(val[2])
else
result = ast AST::ASTArray, :children => [val[0],val[2]]
end
}
The code:
#passwdproc = proc { @password }
keytext = @key.export(
OpenSSL::Cipher::DES.new(:EDE3, :CBC),
@password
)
File.open(@keyfile, "w", 0400) { |f|
f << keytext
}
becomes:
# passwdproc = proc { @password }
keytext = @key.export(
OpenSSL::Cipher::DES.new(:EDE3, :CBC),
@password
)
File.open(@keyfile, "w", 0400) { |f|
f << keytext
}
The code:
end
def to_manifest
"%s { '%s':\n%s\n}" % [self.type.to_s, self.name,
@params.collect { |p, v|
if v.is_a? Array
" #{p} => [\'#{v.join("','")}\']"
else
" #{p} => \'#{v}\'"
end
}.join(",\n")
becomes:
end
def to_manifest
"%s { '%s':\n%s\n}" % [self.type.to_s, self.name,
@params.collect { |p, v|
if v.is_a? Array
" #{p} => [\'#{v.join("','")}\']"
else
" #{p} => \'#{v}\'"
end
}.join(",\n")
The code:
via the augeas tool.
Requires:
- augeas to be installed (http://www.augeas.net)
- ruby-augeas bindings
Sample usage with a string::
augeas{\"test1\" :
context => \"/files/etc/sysconfig/firstboot\",
changes => \"set RUN_FIRSTBOOT YES\",
becomes:
via the augeas tool.
Requires:
- augeas to be installed (http://www.augeas.net)
- ruby-augeas bindings
Sample usage with a string::
augeas{\"test1\" :
context => \"/files/etc/sysconfig/firstboot\",
changes => \"set RUN_FIRSTBOOT YES\",
The code:
names.should_not be_include("root")
end
describe "when generating a purgeable resource" do
it "should be included in the generated resources" do
Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
@resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref)
end
end
describe "when the instance's do not have an ensure property" do
becomes:
names.should_not be_include("root")
end
describe "when generating a purgeable resource" do
it "should be included in the generated resources" do
Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
@resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref)
end
end
describe "when the instance's do not have an ensure property" do
The code:
describe "when the instance's do not have an ensure property" do
it "should not be included in the generated resources" do
@no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo')
Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
@resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
end
end
describe "when the instance's ensure property does not accept absent" do
it "should not be included in the generated resources" do
@no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar')
becomes:
describe "when the instance's do not have an ensure property" do
it "should not be included in the generated resources" do
@no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo')
Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
@resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
end
end
describe "when the instance's ensure property does not accept absent" do
it "should not be included in the generated resources" do
@no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar')
The code:
func = nil
assert_nothing_raised do
func = Puppet::Parser::AST::Function.new(
:name => "template",
:ftype => :rvalue,
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
becomes:
func = nil
assert_nothing_raised do
func = Puppet::Parser::AST::Function.new(
:name => "template",
:ftype => :rvalue,
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
The code:
assert(
@store.allowed?("hostname.madstop.com", "192.168.1.50"),
"hostname not allowed")
assert(
! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),
"subname name allowed")
becomes:
assert(
@store.allowed?("hostname.madstop.com", "192.168.1.50"),
"hostname not allowed")
assert(
! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),
"subname name allowed")
The code:
assert_nothing_raised {
server = Puppet::Network::Handler.fileserver.new(
:Local => true,
:Config => false
)
}
becomes:
assert_nothing_raised {
server = Puppet::Network::Handler.fileserver.new(
:Local => true,
:Config => false
)
}
The code:
'yay',
{ :failonfail => false,
:uid => @user.uid,
:gid => @user.gid }
).returns('output')
output = Puppet::Util::SUIDManager.run_and_capture 'yay',
@user.uid,
@user.gid
becomes:
'yay',
{ :failonfail => false,
:uid => @user.uid,
:gid => @user.gid }
).returns('output')
output = Puppet::Util::SUIDManager.run_and_capture 'yay',
@user.uid,
@user.gid
The code:
).times(1)
pkg.provider.expects(
:aptget
).with(
'-y',
'-q',
'remove',
'faff'
becomes:
).times(1)
pkg.provider.expects(
:aptget
).with(
'-y',
'-q',
'remove',
'faff'
The code:
johnny one two
billy three four\n"
# Just parse and generate, to make sure it's isomorphic.
assert_nothing_raised do
assert_equal(text, @parser.to_file(@parser.parse(text)),
"parsing was not isomorphic")
end
end
def test_valid_attrs
becomes:
johnny one two
billy three four\n"
# Just parse and generate, to make sure it's isomorphic.
assert_nothing_raised do
assert_equal(text, @parser.to_file(@parser.parse(text)),
"parsing was not isomorphic")
end
end
def test_valid_attrs
The code:
"testing",
:onboolean => [true, "An on bool"],
:string => ["a string", "A string arg"]
)
result = []
should = []
assert_nothing_raised("Add args failed") do
@config.addargs(result)
end
@config.each do |name, element|
becomes:
"testing",
:onboolean => [true, "An on bool"],
:string => ["a string", "A string arg"]
)
result = []
should = []
assert_nothing_raised("Add args failed") do
@config.addargs(result)
end
@config.each do |name, element|
Diffstat (limited to 'test/ral')
28 files changed, 935 insertions, 460 deletions
diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index 5ddd27f97..4502a3258 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -43,13 +43,14 @@ class TestTypeAttributes < Test::Unit::TestCase if param == :property assert(inst.property(param), "did not get obj for %s" % param) - assert_equal(true, inst.should(param), + + assert_equal( + true, inst.should(param), + "should value did not get set") else - assert_equal(true, inst[param], - "did not get correct value for %s from symbol" % param) - assert_equal(true, inst[param.to_s], - "did not get correct value for %s from string" % param) + assert_equal(true, inst[param], "did not get correct value for %s from symbol" % param) + assert_equal(true, inst[param.to_s], "did not get correct value for %s from string" % param) end end end @@ -94,7 +95,10 @@ class TestTypeAttributes < Test::Unit::TestCase assert(klass, "did not get class for %s" % name) obj = yield inst, klass assert_instance_of(klass, obj, "did not get object back") - assert_equal("value", inst.value(klass.name), + + assert_equal( + "value", inst.value(klass.name), + "value was not correct from value method") assert_equal("value", obj.value, "value was not correct") end @@ -159,8 +163,7 @@ class TestTypeAttributes < Test::Unit::TestCase end aliases.each do |new, old| - assert_equal(old, type.attr_alias(new), "did not return alias info for %s" % - new) + assert_equal(old, type.attr_alias(new), "did not return alias info for %s" % new) end assert_nil(type.attr_alias(:name), "got invalid alias info for name") @@ -176,11 +179,13 @@ class TestTypeAttributes < Test::Unit::TestCase case old when :one # param - assert_equal(val, inst[new], + + assert_equal( + val, inst[new], + "Incorrect alias value for %s in []" % new) else - assert_equal(val, inst.should(new), - "Incorrect alias value for %s in should" % new) + assert_equal(val, inst.should(new), "Incorrect alias value for %s in should" % new) end assert_equal(val, inst.value(new), "Incorrect alias value for %s" % new) assert_equal(val, inst.value(old), "Incorrect orig value for %s" % old) diff --git a/test/ral/manager/provider.rb b/test/ral/manager/provider.rb index 48d6f2dce..82c27b6c6 100755 --- a/test/ral/manager/provider.rb +++ b/test/ral/manager/provider.rb @@ -37,8 +37,7 @@ class TestTypeProviders < Test::Unit::TestCase # Make sure the provider is always the first parameter created. def test_provider_sorting should = [:name, :ensure] - assert_equal(should, @type.allattrs.reject { |p| ! should.include?(p) }, - "Got wrong order of parameters") + assert_equal(should, @type.allattrs.reject { |p| ! should.include?(p) }, "Got wrong order of parameters") @type.provide(:yay) { } should = [:name, :provider, :ensure] diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb index 662339419..04ecf95ea 100755 --- a/test/ral/manager/type.rb +++ b/test/ral/manager/type.rb @@ -10,16 +10,18 @@ class TestType < Test::Unit::TestCase def test_typemethods Puppet::Type.eachtype { |type| name = nil - assert_nothing_raised("Searching for name for %s caused failure" % - type.to_s) { + assert_nothing_raised("Searching for name for %s caused failure" % type.to_s) { name = type.name } assert(name, "Could not find name for %s" % type.to_s) - assert_equal( + + assert_equal( + type, Puppet::Type.type(name), + "Failed to retrieve %s by name" % name ) @@ -29,13 +31,19 @@ class TestType < Test::Unit::TestCase #end assert_nothing_raised { - assert_not_nil( + + assert_not_nil( + type.properties, + "Properties for %s are nil" % name ) - assert_not_nil( + + assert_not_nil( + type.validproperties, + "Valid properties for %s are nil" % name ) } @@ -43,8 +51,11 @@ class TestType < Test::Unit::TestCase end def test_aliases_are_added_to_catalog - resource = Puppet::Type.type(:file).new( + + resource = Puppet::Type.type(:file).new( + :name => "/path/to/some/missing/file", + :ensure => "file" ) resource.stubs(:path).returns("") @@ -60,8 +71,11 @@ class TestType < Test::Unit::TestCase end def test_aliasing_fails_without_a_catalog - resource = Puppet::Type.type(:file).new( + + resource = Puppet::Type.type(:file).new( + :name => "/no/such/file", + :ensure => "file" ) @@ -73,8 +87,11 @@ class TestType < Test::Unit::TestCase def test_ensuredefault user = nil assert_nothing_raised { - user = Puppet::Type.type(:user).new( + + user = Puppet::Type.type(:user).new( + :name => "pptestAA", + :check => [:uid] ) } @@ -83,8 +100,11 @@ class TestType < Test::Unit::TestCase assert(! user.property(:ensure), "User got an ensure property") assert_nothing_raised { - user = Puppet::Type.type(:user).new( + + user = Puppet::Type.type(:user).new( + :name => "pptestAB", + :comment => "Testingness" ) } @@ -92,8 +112,11 @@ class TestType < Test::Unit::TestCase assert(user.property(:ensure), "User did not add ensure property") assert_nothing_raised { - user = Puppet::Type.type(:user).new( + + user = Puppet::Type.type(:user).new( + :name => "pptestBC", + :comment => "A fake user" ) } @@ -108,7 +131,10 @@ class TestType < Test::Unit::TestCase end } - assert(Puppet::Type.respond_to?(:newmytype), + + assert( + Puppet::Type.respond_to?(:newmytype), + "new<type> method did not get created") obj = nil @@ -144,8 +170,7 @@ class TestType < Test::Unit::TestCase newparam(:rah) do isnamevar end end } - assert_equal(parammethod, Puppet::Type.method(:newparam), - "newparam method got replaced by newtype") + assert_equal(parammethod, Puppet::Type.method(:newparam), "newparam method got replaced by newtype") end def test_newproperty_options @@ -215,8 +240,11 @@ class TestType < Test::Unit::TestCase path = tempfile() assert_nothing_raised do - file = fileclass.create( + + file = fileclass.create( + :title => "Myfile", + :path => path ) end @@ -228,8 +256,11 @@ class TestType < Test::Unit::TestCase # Now make sure we can specify both and still get the right answers assert_nothing_raised do - file = fileclass.create( + + file = fileclass.create( + :title => "Myfile", + :name => path ) end @@ -248,15 +279,21 @@ class TestType < Test::Unit::TestCase echo = Puppet::Util.binary "echo" exec1 = exec2 = nil assert_nothing_raised do - exec1 = Puppet::Type.type(:exec).new( + + exec1 = Puppet::Type.type(:exec).new( + :title => "exec1", + :command => "#{echo} funtest" ) end catalog.add_resource(exec1) assert_nothing_raised do - exec2 = Puppet::Type.type(:exec).new( + + exec2 = Puppet::Type.type(:exec).new( + :title => "exec2", + :command => "#{echo} funtest" ) end @@ -265,16 +302,22 @@ class TestType < Test::Unit::TestCase # Now do files, since they are. This should fail. file1 = file2 = nil path = tempfile() - file1 = Puppet::Type.type(:file).new( + + file1 = Puppet::Type.type(:file).new( + :title => "file1", :path => path, + :content => "yayness" ) catalog.add_resource(file1) - file2 = Puppet::Type.type(:file).new( + + file2 = Puppet::Type.type(:file).new( + :title => "file2", :path => path, + :content => "rahness" ) assert_raise(ArgumentError) { catalog.add_resource(file2) } diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb index 6a745a10c..f1e404ccf 100755 --- a/test/ral/providers/cron/crontab.rb +++ b/test/ral/providers/cron/crontab.rb @@ -23,7 +23,7 @@ class TestCronParsedProvider < Test::Unit::TestCase # a full cron job. These tests assume individual record types will always be correctly # parsed, so all they def sample_crons - unless defined? @sample_crons + unless defined?(@sample_crons) @sample_crons = YAML.load(File.read(File.join(@crondir, "crontab_collections.yaml"))) end @sample_crons @@ -33,7 +33,7 @@ class TestCronParsedProvider < Test::Unit::TestCase # mapping between records and lines. We have plenty of redundancy here because # we use these records to build up our complex, multi-line cron jobs below. def sample_records - unless defined? @sample_records + unless defined?(@sample_records) @sample_records = YAML.load(File.read(File.join(@crondir, "crontab_sample_records.yaml"))) end @sample_records @@ -253,7 +253,10 @@ class TestCronParsedProvider < Test::Unit::TestCase sis.dup.each do |p,v| is.delete(p) if v == :absent end - assert_equal(should, is, + + assert_equal( + should, is, + "Did not parse %s correctly" % file) end @@ -295,7 +298,10 @@ class TestCronParsedProvider < Test::Unit::TestCase str = @provider.to_line(args) } - assert_equal("# Puppet Name: #{name}\n30 * * * * date > /dev/null", str, + + assert_equal( + "# Puppet Name: #{name}\n30 * * * * date > /dev/null", str, + "Cron did not generate correctly") end @@ -370,8 +376,7 @@ class TestCronParsedProvider < Test::Unit::TestCase @provider.flush :target => @me, :command => "/do/something", :record_type => :crontab created = @provider.retrieve(@me) - assert(created.detect { |r| r[:command] == "/do/something" }, - "Did not create cron tab") + assert(created.detect { |r| r[:command] == "/do/something" }, "Did not create cron tab") end # Make sure we correctly bidirectionally parse things. @@ -393,7 +398,10 @@ class TestCronParsedProvider < Test::Unit::TestCase @provider.initvars str += "\n" target.write(str) - assert_equal(str, target.read, + + assert_equal( + str, target.read, + "Did not write correctly") assert_nothing_raised("Could not prefetch with %s" % str.inspect) do @provider.prefetch @@ -402,7 +410,10 @@ class TestCronParsedProvider < Test::Unit::TestCase @provider.flush_target(@me) end - assert_equal(str, target.read, + + assert_equal( + str, target.read, + "Changed in read/write") @provider.clear @@ -435,30 +446,42 @@ class TestCronParsedProvider < Test::Unit::TestCase # Now make some crons that should match matchers = [ - @type.new( + + @type.new( + :name => "yaycron", :minute => [0, 30], :command => "date", + :user => @me ), - @type.new( + + @type.new( + :name => "youtest", :command => "yaytest", + :user => you ) ] nonmatchers = [ - @type.new( + + @type.new( + :name => "footest", :minute => [0, 30], :hour => 1, :command => "fooness", + :user => @me # wrong target ), - @type.new( + + @type.new( + :name => "funtest2", :command => "funtest", + :user => you # wrong target for this cron ) ] @@ -509,8 +532,7 @@ class TestCronParsedProvider < Test::Unit::TestCase # Ignore whitespace differences, since those don't affect function. modtext = text.gsub(/[ \t]+/, " ") modtarget = target.read.gsub(/[ \t]+/, " ") - assert_equal(modtext, modtarget, - "File was not rewritten the same") + assert_equal(modtext, modtarget, "File was not rewritten the same") @provider.clear end @@ -535,14 +557,20 @@ class TestCronParsedProvider < Test::Unit::TestCase end records = @provider.send(:instance_variable_get, "@records") records.each do |r| - assert_equal(:freebsd_special, r[:record_type], + + assert_equal( + :freebsd_special, r[:record_type], + "Did not create lines as freebsd lines") end assert_nothing_raised("Could not flush with %s" % str.inspect) do @provider.flush_target(@me) end - assert_equal(str, target.read, + + assert_equal( + str, target.read, + "Changed in read/write") @provider.clear diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb index cedbf137c..990b0b42c 100755 --- a/test/ral/providers/group.rb +++ b/test/ral/providers/group.rb @@ -63,8 +63,7 @@ class TestGroupProvider < Test::Unit::TestCase def gid(name) %x{nireport / /groups name gid}.split("\n").each { |line| group, id = line.chomp.split(/\s+/) - assert(id =~ /^-?\d+$/, "Group id %s for %s is not a number" % - [id.inspect, group]) + assert(id =~ /^-?\d+$/, "Group id %s for %s is not a number" % [id.inspect, group]) if group == name return Integer(id) end diff --git a/test/ral/providers/host/parsed.rb b/test/ral/providers/host/parsed.rb index 839761286..0339f7c27 100755 --- a/test/ral/providers/host/parsed.rb +++ b/test/ral/providers/host/parsed.rb @@ -36,7 +36,7 @@ class TestParsedHostProvider < Test::Unit::TestCase end def mkhosthash - if defined? @hcount + if defined?(@hcount) @hcount += 1 else @hcount = 1 @@ -100,12 +100,15 @@ class TestParsedHostProvider < Test::Unit::TestCase instances = @provider.parse(text) end - assert_equal([ + + assert_equal( + [ {:record_type => :comment, :line => "# comment one"}, {:record_type => :blank, :line => ""}, {:record_type => :parsed, :name => "myhost", :ip => "192.168.43.56", :host_aliases => %w{another host}}, {:record_type => :blank, :line => " "}, {:record_type => :comment, :line => "# another comment"}, + {:record_type => :parsed, :name => "anotherhost", :ip => "192.168.43.57", :host_aliases => []} ], instances) @@ -145,7 +148,10 @@ class TestParsedHostProvider < Test::Unit::TestCase # Make sure we get the host back assert_nothing_raised { - assert(file.read.include?(host.name), + + assert( + file.read.include?(host.name), + "Did not flush host to disk") } @@ -155,7 +161,10 @@ class TestParsedHostProvider < Test::Unit::TestCase assert_nothing_raised { host.flush - assert(! file.read.include?(name[0]), + + assert( + ! file.read.include?(name[0]), + "Did not remove host_aliases from disk") } diff --git a/test/ral/providers/mailalias/aliases.rb b/test/ral/providers/mailalias/aliases.rb index 6406e83e9..76bbc60c6 100755 --- a/test/ral/providers/mailalias/aliases.rb +++ b/test/ral/providers/mailalias/aliases.rb @@ -26,7 +26,7 @@ class TestMailaliasAliasesProvider < Test::Unit::TestCase end def mkalias(name = "me") - if defined? @pcount + if defined?(@pcount) @pcount += 1 else @pcount = 1 diff --git a/test/ral/providers/package.rb b/test/ral/providers/package.rb index 4435188be..b408d9482 100755 --- a/test/ral/providers/package.rb +++ b/test/ral/providers/package.rb @@ -83,8 +83,7 @@ class TestPackageProvider < Test::Unit::TestCase assert_nothing_raised("Could not query provider") do result = provider.query end - assert((result == :listed or result.is_a?(Hash)), - "query did not return hash or :listed") + assert((result == :listed or result.is_a?(Hash)), "query did not return hash or :listed") if result == :listed assert(provider.resource.is(:ensure) != :absent, msg) else @@ -192,8 +191,7 @@ class TestPackageProvider < Test::Unit::TestCase end provider.flush new = provider.properties - assert(current != new, "package was not upgraded: %s did not change" % - current.inspect) + assert(current != new, "package was not upgraded: %s did not change" % current.inspect) end unless versions.empty? @@ -204,8 +202,7 @@ class TestPackageProvider < Test::Unit::TestCase end provider.flush new = provider.properties - assert(current != new, "package was not upgraded: %s did not change" % - current.inspect) + assert(current != new, "package was not upgraded: %s did not change" % current.inspect) end # Now call 'latest' after the package is installed diff --git a/test/ral/providers/package/aptitude.rb b/test/ral/providers/package/aptitude.rb index 113085c75..ba736f948 100755 --- a/test/ral/providers/package/aptitude.rb +++ b/test/ral/providers/package/aptitude.rb @@ -17,30 +17,36 @@ class AptitudePackageProviderTest < PuppetTest::TestCase def test_install pkg = @type.new :name => 'faff', - :provider => :aptitude, - :ensure => :present, - :source => "/tmp/faff.deb" + :provider => :aptitude, + :ensure => :present, + :source => "/tmp/faff.deb" pkg.provider.expects( - :dpkgquery - ).with( - '-W', - '--showformat', - '${Status} ${Package} ${Version}\n', - 'faff' - ).returns( + :dpkgquery + + ).with( + + '-W', + '--showformat', + '${Status} ${Package} ${Version}\n', + + 'faff' + ).returns( "deinstall ok config-files faff 1.2.3-1\n" - ).times(1) + ).times(1) pkg.provider.expects( - :aptitude - ).with( - '-y', - '-o', - 'DPkg::Options::=--force-confold', - :install, - 'faff' - ).returns(0) + :aptitude + + ).with( + + '-y', + '-o', + 'DPkg::Options::=--force-confold', + :install, + + 'faff' + ).returns(0) assert_apply( pkg ) end @@ -49,22 +55,28 @@ class AptitudePackageProviderTest < PuppetTest::TestCase pkg = @type.new :name => 'faff', :provider => :aptitude, :ensure => :purged pkg.provider.expects( - :dpkgquery - ).with( - '-W', - '--showformat', - '${Status} ${Package} ${Version}\n', - 'faff' - ).returns( + :dpkgquery + + ).with( + + '-W', + '--showformat', + '${Status} ${Package} ${Version}\n', + + 'faff' + ).returns( "install ok installed faff 1.2.3-1\n" - ).times(1) + ).times(1) pkg.provider.expects( - :aptitude - ).with( - '-y', - 'purge', - 'faff' - ).returns(0) + :aptitude + + ).with( + + '-y', + 'purge', + + 'faff' + ).returns(0) assert_apply( pkg ) end diff --git a/test/ral/providers/package/aptrpm.rb b/test/ral/providers/package/aptrpm.rb index a3010cc92..dbb6a0029 100755 --- a/test/ral/providers/package/aptrpm.rb +++ b/test/ral/providers/package/aptrpm.rb @@ -15,28 +15,34 @@ class AptrpmPackageProviderTest < PuppetTest::TestCase def test_install pkg = @type.new :name => 'faff', - :provider => :aptrpm, - :ensure => :present, - :source => "/tmp/faff.rpm" + :provider => :aptrpm, + :ensure => :present, + :source => "/tmp/faff.rpm" pkg.provider.expects( - :rpm - ).with( - '-q', - 'faff', - '--nosignature', - '--nodigest', - '--qf', - "%{NAME}-%{VERSION}-%{RELEASE} %{VERSION}-%{RELEASE}\n" - ).raises(Puppet::ExecutionFailure, "couldn't find rpm").times(1) + :rpm + + ).with( + + '-q', + 'faff', + '--nosignature', + '--nodigest', + '--qf', + + "%{NAME}-%{VERSION}-%{RELEASE} %{VERSION}-%{RELEASE}\n" + ).raises(Puppet::ExecutionFailure, "couldn't find rpm").times(1) pkg.provider.expects( - :aptget - ).with( - '-q', - '-y', - "install", - 'faff' + :aptget + + ).with( + + '-q', + '-y', + "install", + + 'faff' ).returns(0) pkg.evaluate.each { |state| state.forward } @@ -46,24 +52,30 @@ class AptrpmPackageProviderTest < PuppetTest::TestCase pkg = @type.new :name => 'faff', :provider => :aptrpm, :ensure => :absent pkg.provider.expects( - :rpm - ).with( - '-q', - 'faff', - '--nosignature', - '--nodigest', - '--qf', - "%{NAME}-%{VERSION}-%{RELEASE} %{VERSION}-%{RELEASE}\n" + :rpm + + ).with( + + '-q', + 'faff', + '--nosignature', + '--nodigest', + '--qf', + + "%{NAME}-%{VERSION}-%{RELEASE} %{VERSION}-%{RELEASE}\n" ).returns( "faff-1.2.3-1 1.2.3-1\n" ).times(1) pkg.provider.expects( - :aptget - ).with( - '-y', - '-q', - 'remove', - 'faff' + :aptget + + ).with( + + '-y', + '-q', + 'remove', + + 'faff' ).returns(0) pkg.evaluate.each { |state| state.forward } diff --git a/test/ral/providers/parsedfile.rb b/test/ral/providers/parsedfile.rb index 9794a71bb..a1d2435d1 100755 --- a/test/ral/providers/parsedfile.rb +++ b/test/ral/providers/parsedfile.rb @@ -36,8 +36,7 @@ class TestParsedFile < Test::Unit::TestCase # A simple block to skip the complexity of a full transaction. def apply(resource) [:one, :two, :ensure, :target].each do |st| - Puppet.info "Setting %s: %s => %s" % - [resource[:name], st, resource.should(st)] + Puppet.info "Setting %s: %s => %s" % [resource[:name], st, resource.should(st)] resource.provider.send(st.to_s + "=", resource.should(st)) end end @@ -51,8 +50,7 @@ class TestParsedFile < Test::Unit::TestCase end def mkprovider(name = :parsed) - @provider = @type.provide(name, :parent => Puppet::Provider::ParsedFile, - :filetype => :ram, :default_target => "yayness") do + @provider = @type.provide(name, :parent => Puppet::Provider::ParsedFile, :filetype => :ram, :default_target => "yayness") do record_line name, :fields => %w{name one two} end end @@ -63,7 +61,7 @@ class TestParsedFile < Test::Unit::TestCase end def teardown - if defined? @provider + if defined?(@provider) @type.unprovide(@provider.name) @provider = nil end @@ -369,16 +367,14 @@ class TestParsedFile < Test::Unit::TestCase assert_equal(:c, one.provider.two) # And make sure it's right on disk - assert(prov.target_object(:yayness).read.include?("one a c"), - "Did not write out correct data") + assert(prov.target_object(:yayness).read.include?("one a c"), "Did not write out correct data") # Make sure the second resource has not been modified assert_equal("a", two.provider.one, "Two was flushed early") assert_equal("c", two.provider.two, "Two was flushed early") # And on disk - assert(prov.target_object(:yayness).read.include?("two a c"), - "Wrote out other resource") + assert(prov.target_object(:yayness).read.include?("two a c"), "Wrote out other resource") # Now fetch the data again and make sure we're still right assert_nothing_raised { prov.prefetch(resources) } @@ -422,8 +418,7 @@ class TestParsedFile < Test::Unit::TestCase end # And make sure our resource doesn't appear twice in the file. - assert_equal("yay b c\n", prov.target_object(:basic).read, - "Wrote record to file twice") + assert_equal("yay b c\n", prov.target_object(:basic).read, "Wrote record to file twice") end # Make sure a record can switch targets. @@ -452,8 +447,7 @@ class TestParsedFile < Test::Unit::TestCase end check = proc do |target, name| - assert(prov.target_object(target).read.include?("%s a c" % name), - "Did not sync %s" % name) + assert(prov.target_object(target).read.include?("%s a c" % name), "Did not sync %s" % name) end # Make sure the data is there check.call(:first, :first) @@ -479,8 +473,7 @@ class TestParsedFile < Test::Unit::TestCase check.call(:second, :mover) # And make sure the mover is no longer in the first file - assert(prov.target_object(:first) !~ /mover/, - "Mover was not removed from first file") + assert(prov.target_object(:first) !~ /mover/, "Mover was not removed from first file") end # Make sure that 'ensure' correctly calls 'sync' on all properties. @@ -497,7 +490,10 @@ class TestParsedFile < Test::Unit::TestCase prov.target_object(:first).write "ondisk a c\n" prov.prefetch("ondisk" => ondisk, "notdisk" => notdisk) - assert_equal(:present, notdisk.should(:ensure), + + assert_equal( + :present, notdisk.should(:ensure), + "Did not get default ensure value") # Try creating the object @@ -528,10 +524,8 @@ class TestParsedFile < Test::Unit::TestCase assert_nothing_raised { notdisk.flush } # And make sure it's no longer present - assert(prov.target_object(:first).read !~ /^notdisk/, - "Did not remove thing from disk") - assert(prov.target_object(:first).read =~ /^ondisk/, - "Lost object on disk") + assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk") + assert(prov.target_object(:first).read =~ /^ondisk/, "Lost object on disk") assert_equal(:present, ondisk.provider.ensure) end @@ -588,14 +582,14 @@ class TestParsedFile < Test::Unit::TestCase end assert(bills_values[bill.property(:one)], - "Bill does not have a value for 'one'") + "Bill does not have a value for 'one'") assert(bills_values[bill.property(:one)], - "Bill does not have a value for 'one' on second try") + "Bill does not have a value for 'one' on second try") assert_nothing_raised do bill.retrieve end assert(bills_values[bill.property(:one)], - "bill's value for 'one' disappeared") + "bill's value for 'one' disappeared") end # Make sure that creating a new resource finds existing records in memory @@ -615,7 +609,10 @@ class TestParsedFile < Test::Unit::TestCase # Make sure invalid fields always show up as insync def test_invalid_fields - prov = @type.provide(:test, :parent => Puppet::Provider::ParsedFile, + + prov = @type.provide( + :test, :parent => Puppet::Provider::ParsedFile, + :filetype => :ram, :default_target => :yayness) do record_line :test, :fields => %w{name two} end @@ -640,7 +637,10 @@ class TestParsedFile < Test::Unit::TestCase # Make sure we call the prefetch hook at the right place. def test_prefetch_hook - prov = @type.provide(:test, :parent => Puppet::Provider::ParsedFile, + + prov = @type.provide( + :test, :parent => Puppet::Provider::ParsedFile, + :filetype => :ram, :default_target => :yayness) do def self.prefetch_hook(records) @@ -678,14 +678,16 @@ class TestParsedFile < Test::Unit::TestCase otarget.write("oname b d\n") # Now make a resource that targets elsewhat. - res = @type.new(:name => "test", :one => "a", :two => "c", - :target => opath) + res = @type.new(:name => "test", :one => "a", :two => "c", :target => opath) assert(res.property(:target), "Target is a parameter, not a property") assert_apply(res) - assert_equal("oname b d\ntest a c\n", otarget.read, + + assert_equal( + "oname b d\ntest a c\n", otarget.read, + "did not get correct results in specified target") end end diff --git a/test/ral/providers/provider.rb b/test/ral/providers/provider.rb index 79535bef2..e7625b95d 100755 --- a/test/ral/providers/provider.rb +++ b/test/ral/providers/provider.rb @@ -213,11 +213,17 @@ class TestProvider < Test::Unit::TestCase out = detail.to_s end - assert(out =~ /A Failure/, - "Did not receive command output on failure") - assert(out =~ /Execution of/, - "Did not receive info wrapper on failure") + assert( + out =~ /A Failure/, + + "Did not receive command output on failure") + + + assert( + out =~ /Execution of/, + + "Did not receive info wrapper on failure") end def test_mk_resource_methods @@ -236,14 +242,20 @@ class TestProvider < Test::Unit::TestCase assert(prov.public_method_defined?(param), "no getter for %s" % param) assert(prov.public_method_defined?(param + "="), "no setter for %s" % param) - assert_equal(:absent, obj.send(param), - "%s did not default to :absent") + + assert_equal( + :absent, obj.send(param), + + "%s did not default to :absent") val = "testing %s" % param assert_nothing_raised("Could not call setter for %s" % param) do obj.send(param + "=", val) end - assert_equal(val, obj.send(param), - "did not get correct value for %s" % param) + + assert_equal( + val, obj.send(param), + + "did not get correct value for %s" % param) end end @@ -382,47 +394,32 @@ class TestProviderFeatures < Test::Unit::TestCase end resource = @type.new(:name => "foo") - {:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha], - :mixed => [], :neither => []}.each do |name, should| - should.sort! { |a,b| a.to_s <=> b.to_s } - provider = @type.provider(name) - assert(provider, "Could not find provider %s" % name) - assert_equal(should, provider.features, - "Provider %s has incorrect features" % name) - - inst = provider.new(resource) - # Make sure the boolean methods work on both the provider and - # instance. - @features.keys.each do |feature| - method = feature.to_s + "?" - assert(inst.respond_to?(method), - "No boolean instance method for %s on %s" % - [name, feature]) - assert(provider.respond_to?(method), - "No boolean class method for %s on %s" % [name, feature]) - - if should.include?(feature) - assert(provider.feature?(feature), - "class missing feature? %s" % feature) - assert(inst.feature?(feature), - "instance missing feature? %s" % feature) - assert(provider.send(method), - "class missing feature %s" % feature) - assert(inst.send(method), - "instance missing feature %s" % feature) - assert(inst.satisfies?(feature), - "instance.satisfy %s returned false" % feature) + {:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha], :mixed => [], :neither => []}.each do |name, should| + should.sort! { |a,b| a.to_s <=> b.to_s } + provider = @type.provider(name) + assert(provider, "Could not find provider %s" % name) + assert_equal(should, provider.features, "Provider %s has incorrect features" % name) + + inst = provider.new(resource) + # Make sure the boolean methods work on both the provider and + # instance. + @features.keys.each do |feature| + method = feature.to_s + "?" + assert(inst.respond_to?(method), "No boolean instance method for %s on %s" % [name, feature]) + assert(provider.respond_to?(method), "No boolean class method for %s on %s" % [name, feature]) + + if should.include?(feature) + assert(provider.feature?(feature), "class missing feature? %s" % feature) + assert(inst.feature?(feature), "instance missing feature? %s" % feature) + assert(provider.send(method), "class missing feature %s" % feature) + assert(inst.send(method), "instance missing feature %s" % feature) + assert(inst.satisfies?(feature), "instance.satisfy %s returned false" % feature) else - assert(! provider.feature?(feature), - "class has feature? %s" % feature) - assert(! inst.feature?(feature), - "instance has feature? %s" % feature) - assert(! provider.send(method), - "class has feature %s" % feature) - assert(! inst.send(method), - "instance has feature %s" % feature) - assert(! inst.satisfies?(feature), - "instance.satisfy %s returned true" % feature) + assert(! provider.feature?(feature), "class has feature? %s" % feature) + assert(! inst.feature?(feature), "instance has feature? %s" % feature) + assert(! provider.send(method), "class has feature %s" % feature) + assert(! inst.send(method), "instance has feature %s" % feature) + assert(! inst.satisfies?(feature), "instance.satisfy %s returned true" % feature) end end @@ -431,8 +428,7 @@ class TestProviderFeatures < Test::Unit::TestCase Puppet[:trace] = true Puppet::Type.loadall Puppet::Type.eachtype do |type| - assert(type.respond_to?(:feature), - "No features method defined for %s" % type.name) + assert(type.respond_to?(:feature), "No features method defined for %s" % type.name) end end @@ -443,9 +439,15 @@ class TestProviderFeatures < Test::Unit::TestCase # Define a provider with nothing provider = @type.provide(:nothing) {} - assert(provider.respond_to?(:has_features), + + assert( + provider.respond_to?(:has_features), + "Provider did not get 'has_features' method added") - assert(provider.respond_to?(:has_feature), + + assert( + provider.respond_to?(:has_feature), + "Provider did not get the 'has_feature' alias method") # One with the numeric methods and nothing else diff --git a/test/ral/providers/service/base.rb b/test/ral/providers/service/base.rb index e23e2fd11..015905180 100755 --- a/test/ral/providers/service/base.rb +++ b/test/ral/providers/service/base.rb @@ -22,10 +22,13 @@ class TestBaseServiceProvider < Test::Unit::TestCase end commands[c.to_sym] = path end - service = Puppet::Type.type(:service).new( + + service = Puppet::Type.type(:service).new( + :name => "yaytest", :provider => :base, :start => "%s %s" % [commands[:touch], running], :status => "%s -f %s" % [commands[:test], running], + :stop => "%s %s" % [commands[:rm], running] ) @@ -51,11 +54,14 @@ class TestBaseServiceProvider < Test::Unit::TestCase # Testing #454 def test_that_failures_propagate nope = "/no/such/command" - service = Puppet::Type.type(:service).new( + + service = Puppet::Type.type(:service).new( + :name => "yaytest", :provider => :base, :start => nope, :status => nope, :stop => nope, + :restart => nope ) diff --git a/test/ral/providers/sshkey/parsed.rb b/test/ral/providers/sshkey/parsed.rb index cad758568..8a18d5e9a 100755 --- a/test/ral/providers/sshkey/parsed.rb +++ b/test/ral/providers/sshkey/parsed.rb @@ -24,7 +24,7 @@ class TestParsedSSHKey < Test::Unit::TestCase end def mkkey(name = "host.domain.com") - if defined? @pcount + if defined?(@pcount) @pcount += 1 else @pcount = 1 @@ -96,11 +96,14 @@ class TestParsedSSHKey < Test::Unit::TestCase assert_equal("one", result[:name], "Did not call post hook") assert_equal(%w{two}, result[:host_aliases], "Did not call post hook") - assert_equal("one,two type key", + + assert_equal( + "one,two type key", @provider.to_line(:record_type => :parsed, :name => "one", :host_aliases => %w{two}, :type => "type", + :key => "key"), "Did not use pre-hook when generating line" ) diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb index 9abf850ad..7b031891b 100755 --- a/test/ral/providers/user.rb +++ b/test/ral/providers/user.rb @@ -192,8 +192,11 @@ class TestUserProvider < Test::Unit::TestCase val = user.send(property) } - assert(val != :absent, - "Property %s is missing" % property) + + assert( + val != :absent, + + "Property %s is missing" % property) assert(val, "Did not get value for %s" % property) end @@ -202,12 +205,18 @@ class TestUserProvider < Test::Unit::TestCase def test_exists user = mkuser("nosuchuserok") - assert(! user.exists?, - "Fake user exists?") + + assert( + ! user.exists?, + + "Fake user exists?") user = mkuser(@me) - assert(user.exists?, - "I don't exist?") + + assert( + user.exists?, + + "I don't exist?") end def attrtest_ensure(user) @@ -238,14 +247,20 @@ class TestUserProvider < Test::Unit::TestCase user.comment = newname } - assert_equal(newname, current?(:comment, user), + + assert_equal( + newname, current?(:comment, user), + "Comment was not changed") assert_nothing_raised { user.comment = old } - assert_equal(old, current?(:comment, user), + + assert_equal( + old, current?(:comment, user), + "Comment was not reverted") end @@ -278,7 +293,10 @@ class TestUserProvider < Test::Unit::TestCase user.shell = newshell } - assert_equal(newshell, current?(:shell, user), + + assert_equal( + newshell, current?(:shell, user), + "Shell was not changed") assert_nothing_raised { @@ -292,8 +310,8 @@ class TestUserProvider < Test::Unit::TestCase old = current?(:gid, user) newgroup = %w{nogroup nobody staff users daemon}.find { |gid| - begin - group = Etc.getgrnam(gid) + begin + group = Etc.getgrnam(gid) rescue ArgumentError => detail next end @@ -369,9 +387,12 @@ class TestUserProvider < Test::Unit::TestCase 5.times do |i| i += 1 name = "pptstgr%s" % i - tmpgroup = Puppet::Type.type(:group).new( - :name => name, - :gid => max + i + + tmpgroup = Puppet::Type.type(:group).new( + + :name => name, + + :gid => max + i ) groups << tmpgroup @@ -439,7 +460,7 @@ class TestUserProvider < Test::Unit::TestCase } assert_equal("Puppet's Testing User pptest", - user.comment, + user.comment, "Comment was not set") assert_nothing_raised { @@ -507,8 +528,11 @@ class TestUserProvider < Test::Unit::TestCase user2.resource[:allowdupe] = :true } assert_nothing_raised { user2.create } - assert_equal(:present, user2.ensure, - "User did not get created") + + assert_equal( + :present, user2.ensure, + + "User did not get created") end else $stderr.puts "Not root; skipping user creation/modification tests" @@ -528,10 +552,16 @@ class TestUserProvider < Test::Unit::TestCase user = useradd.new(fakeresource) } - assert_equal("-d", user.send(:flag, :home), + + assert_equal( + "-d", user.send(:flag, :home), + "Incorrect home flag") - assert_equal("-s", user.send(:flag, :shell), + + assert_equal( + "-s", user.send(:flag, :shell), + "Incorrect shell flag") end diff --git a/test/ral/providers/user/useradd.rb b/test/ral/providers/user/useradd.rb index 25798d637..7dedeefc9 100755 --- a/test/ral/providers/user/useradd.rb +++ b/test/ral/providers/user/useradd.rb @@ -35,7 +35,10 @@ class UserAddProviderTest < PuppetTest::TestCase def test_features [:manages_homedir].each do |feature| - assert(@provider.feature?(feature), + + assert( + @provider.feature?(feature), + "useradd provider is missing %s" % feature) end end @@ -56,8 +59,7 @@ class UserAddProviderTest < PuppetTest::TestCase "Got incorrect command") if %w{Fedora RedHat}.include?(Facter.value(:operatingsystem)) - assert(params.include?("-M"), - "Did not disable homedir creation on red hat") + assert(params.include?("-M"), "Did not disable homedir creation on red hat") params.delete("-M") end @@ -72,8 +74,7 @@ class UserAddProviderTest < PuppetTest::TestCase :uid => "-u", :comment => "-c"} flags.each do |param, flag| - assert_equal(@vals[param], options[flag], - "Got incorrect value for %s" % param) + assert_equal(@vals[param], options[flag], "Got incorrect value for %s" % param) end true @@ -87,7 +88,10 @@ class UserAddProviderTest < PuppetTest::TestCase @vals[:managehome] = true setup_user - assert(@user.provider.respond_to?(:manages_homedir?), + + assert( + @user.provider.respond_to?(:manages_homedir?), + "provider did not get managehome test set") assert(@user.managehome?, "provider did not get managehome") @@ -96,12 +100,9 @@ class UserAddProviderTest < PuppetTest::TestCase @user.expects(:managehome?).returns(true) @user.provider.expects(:execute).with do |params| - assert_equal(params[0], @provider.command(:add), - "useradd was not called") - assert(params.include?("-m"), - "Did not add -m when managehome was in affect") - assert(! params.include?("-M"), - "Added -M when managehome was in affect") + assert_equal(params[0], @provider.command(:add), "useradd was not called") + assert(params.include?("-m"), "Did not add -m when managehome was in affect") + assert(! params.include?("-M"), "Added -M when managehome was in affect") true end @@ -116,14 +117,11 @@ class UserAddProviderTest < PuppetTest::TestCase @user.expects(:managehome?).returns(false) @user.provider.expects(:execute).with do |params| - assert_equal(params[0], @provider.command(:add), - "useradd was not called") + assert_equal(params[0], @provider.command(:add), "useradd was not called") if %w{Fedora RedHat}.include?(Facter.value(:operatingsystem)) - assert(params.include?("-M"), - "Did not add -M on Red Hat") + assert(params.include?("-M"), "Did not add -M on Red Hat") end - assert(! params.include?("-m"), - "Added -m when managehome was disabled") + assert(! params.include?("-m"), "Added -m when managehome was disabled") true end @@ -135,7 +133,10 @@ class UserAddProviderTest < PuppetTest::TestCase @vals[:allowdupe] = true setup_user - assert(@user.provider.respond_to?(:allows_duplicates?), + + assert( + @user.provider.respond_to?(:allows_duplicates?), + "provider did not get allowdupe test set") assert(@user.allowdupe?, "provider did not get allowdupe") @@ -144,10 +145,8 @@ class UserAddProviderTest < PuppetTest::TestCase @user.expects(:allowdupe?).returns(true) @user.provider.expects(:execute).with do |params| - assert_equal(params[0], @provider.command(:add), - "useradd was not called") - assert(params.include?("-o"), - "Did not add -o when allowdupe was in affect") + assert_equal(params[0], @provider.command(:add), "useradd was not called") + assert(params.include?("-o"), "Did not add -o when allowdupe was in affect") true end @@ -162,10 +161,8 @@ class UserAddProviderTest < PuppetTest::TestCase @user.expects(:allowdupe?).returns(false) @user.provider.expects(:execute).with do |params| - assert_equal(params[0], @provider.command(:add), - "useradd was not called") - assert(! params.include?("-o"), - "Added -o when allowdupe was disabled") + assert_equal(params[0], @provider.command(:add), "useradd was not called") + assert(! params.include?("-o"), "Added -o when allowdupe was disabled") true end @@ -181,8 +178,7 @@ class UserAddProviderTest < PuppetTest::TestCase setup_user @user.provider.expects(:execute).with do |params| - assert_equal(params[0], @provider.command(:add), - "useradd was not called") + assert_equal(params[0], @provider.command(:add), "useradd was not called") params.shift options = {} params.each_with_index do |p, i| @@ -190,8 +186,7 @@ class UserAddProviderTest < PuppetTest::TestCase options[p] = params[i + 1] end end - assert_equal(options["-p"], @vals[:password], - "Did not set password in useradd call") + assert_equal(options["-p"], @vals[:password], "Did not set password in useradd call") true end @@ -202,8 +197,7 @@ class UserAddProviderTest < PuppetTest::TestCase @vals[:password] = "somethingelse" @user.provider.expects(:execute).with do |params| - assert_equal(params[0], @provider.command(:modify), - "usermod was not called") + assert_equal(params[0], @provider.command(:modify), "usermod was not called") options = {} params.each_with_index do |p, i| @@ -211,7 +205,10 @@ class UserAddProviderTest < PuppetTest::TestCase options[p] = params[i + 1] end end - assert_equal(options["-p"], @vals[:password], + + assert_equal( + options["-p"], @vals[:password], + "Did not set password in useradd call") true end diff --git a/test/ral/type/cron.rb b/test/ral/type/cron.rb index 2c0a70199..fc2d03e93 100755 --- a/test/ral/type/cron.rb +++ b/test/ral/type/cron.rb @@ -124,10 +124,13 @@ class TestCron < Test::Unit::TestCase name = "yaytest" command = "date > /dev/null " assert_nothing_raised { + cron = @crontype.new( + :name => name, :command => "date > /dev/null ", :month => "May", + :user => @me ) } @@ -195,12 +198,10 @@ class TestCron < Test::Unit::TestCase } if value.is_a?(Integer) - assert_equal([value.to_s], cron.should(param), - "Cron value was not set correctly") + assert_equal([value.to_s], cron.should(param), "Cron value was not set correctly") end when :invalid - assert_raise(Puppet::Error, "%s is incorrectly a valid %s" % - [value, param]) { + assert_raise(Puppet::Error, "%s is incorrectly a valid %s" % [value, param]) { cron[param] = value } end @@ -219,10 +220,13 @@ class TestCron < Test::Unit::TestCase eachprovider do |provider| cron = nil assert_nothing_raised { + cron = @crontype.new( + :command => "/bin/date > /dev/null", :minute => [0, 30], :name => "crontest", + :provider => provider.name ) } @@ -245,10 +249,13 @@ class TestCron < Test::Unit::TestCase def test_fieldremoval cron = nil assert_nothing_raised { + cron = @crontype.new( + :command => "/bin/date > /dev/null", :minute => [0, 30], :name => "crontest", + :provider => :crontab ) } @@ -277,9 +284,12 @@ class TestCron < Test::Unit::TestCase cleanup { provider.filetype = ft } setme - cron = @crontype.new(:name => "testing", + + cron = @crontype.new( + :name => "testing", :minute => [0, 30], :command => "/bin/testing", + :user => @me ) # Write it to our file @@ -294,8 +304,11 @@ class TestCron < Test::Unit::TestCase crons.each do |cron| assert_instance_of(@crontype, cron, "Did not receive a real cron object") - assert_instance_of(String, cron.value(:user), - "Cron user is not a string") + + assert_instance_of( + String, cron.value(:user), + + "Cron user is not a string") end end @@ -334,11 +347,11 @@ class TestCron < Test::Unit::TestCase def provider_set(cron, param, value) - unless param =~ /=$/ - param = "%s=" % param - end + unless param =~ /=$/ + param = "%s=" % param + end - cron.provider.send(param, value) + cron.provider.send(param, value) end def test_value @@ -352,8 +365,8 @@ class TestCron < Test::Unit::TestCase assert(property, "Did not get %s property" % param) assert_nothing_raised { -# property.is = :absent - provider_set(cron, param, :absent) + # property.is = :absent + provider_set(cron, param, :absent) } val = "*" @@ -419,10 +432,13 @@ class TestCron < Test::Unit::TestCase crons = [] users = ["root", nonrootuser.name] users.each do |user| + cron = Puppet::Type.type(:cron).new( + :name => "testcron-#{user}", :user => user, :command => "/bin/echo", + :minute => [0,30] ) crons << cron @@ -439,9 +455,11 @@ class TestCron < Test::Unit::TestCase next if user == other text = provider.target_object(other).read - assert(text !~ /testcron-#{user}/, - "%s's cron job is in %s's tab" % - [user, other]) + + assert( + text !~ /testcron-#{user}/, + + "%s's cron job is in %s's tab" % [user, other]) end end end @@ -450,20 +468,27 @@ class TestCron < Test::Unit::TestCase def test_default_user crontab = @crontype.provider(:crontab) if crontab.suitable? + inst = @crontype.new( + :name => "something", :command => "/some/thing", + :provider => :crontab) - assert_equal(Etc.getpwuid(Process.uid).name, inst.should(:user), - "user did not default to current user with crontab") - assert_equal(Etc.getpwuid(Process.uid).name, inst.should(:target), - "target did not default to current user with crontab") + assert_equal(Etc.getpwuid(Process.uid).name, inst.should(:user), "user did not default to current user with crontab") + assert_equal(Etc.getpwuid(Process.uid).name, inst.should(:target), "target did not default to current user with crontab") # Now make a new cron with a user, and make sure it gets copied # over - inst = @crontype.new(:name => "yay", :command => "/some/thing", - :user => "bin", :provider => :crontab) - assert_equal("bin", inst.should(:target), - "target did not default to user with crontab") + + inst = @crontype.new( + :name => "yay", :command => "/some/thing", + + :user => "bin", :provider => :crontab) + + assert_equal( + "bin", inst.should(:target), + + "target did not default to user with crontab") end end diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb index 98d111444..cc163ead5 100755 --- a/test/ral/type/exec.rb +++ b/test/ral/type/exec.rb @@ -11,8 +11,11 @@ class TestExec < Test::Unit::TestCase command = nil output = nil assert_nothing_raised { + command = Puppet::Type.type(:exec).new( + :command => "/bin/echo", + :returns => val ) } @@ -29,8 +32,11 @@ class TestExec < Test::Unit::TestCase ) } assert_nothing_raised { + command = Puppet::Type.type(:exec).new( + :command => "echo", + :path => "/usr/bin:/bin:/usr/sbin:/sbin" ) } @@ -40,8 +46,11 @@ class TestExec < Test::Unit::TestCase ) } assert_nothing_raised { + command = Puppet::Type.type(:exec).new( + :command => "/bin/echo", + :path => "/usr/bin:/bin:/usr/sbin:/sbin" ) } @@ -49,23 +58,32 @@ class TestExec < Test::Unit::TestCase def test_nonzero_returns assert_nothing_raised { + command = Puppet::Type.type(:exec).new( + :command => "mkdir /this/directory/does/not/exist", :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :returns => 1 ) } assert_nothing_raised { + command = Puppet::Type.type(:exec).new( + :command => "touch /etc", :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :returns => 1 ) } assert_nothing_raised { + command = Puppet::Type.type(:exec).new( + :command => "thiscommanddoesnotexist", :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :returns => 127 ) } @@ -78,10 +96,13 @@ class TestExec < Test::Unit::TestCase Dir.getwd } assert_nothing_raised { + command = Puppet::Type.type(:exec).new( + :command => "pwd", :cwd => dir, :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :returns => 0 ) } @@ -95,9 +116,12 @@ class TestExec < Test::Unit::TestCase tmpfile = tempfile() @@tmpfiles.push tmpfile trans = nil - file = Puppet::Type.type(:file).new( - :path => tmpfile, - :content => "yay" + + file = Puppet::Type.type(:file).new( + + :path => tmpfile, + + :content => "yay" ) # Get the file in sync assert_apply(file) @@ -105,10 +129,13 @@ class TestExec < Test::Unit::TestCase # Now make an exec maker = tempfile() assert_nothing_raised { + cmd = Puppet::Type.type(:exec).new( + :command => "touch %s" % maker, :path => "/usr/bin:/bin:/usr/sbin:/sbin", :subscribe => file, + :refreshonly => true ) } @@ -131,9 +158,12 @@ class TestExec < Test::Unit::TestCase def test_refreshonly cmd = true assert_nothing_raised { + cmd = Puppet::Type.type(:exec).new( + :command => "pwd", :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :refreshonly => true ) } @@ -154,9 +184,12 @@ class TestExec < Test::Unit::TestCase exec = nil assert(! FileTest.exists?(file), "File already exists") assert_nothing_raised { + exec = Puppet::Type.type(:exec).new( + :command => "touch %s" % file, :path => "/usr/bin:/bin:/usr/sbin:/sbin", + :creates => file ) } @@ -173,15 +206,21 @@ class TestExec < Test::Unit::TestCase sh = %x{which sh} File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" } - file = Puppet::Type.type(:file).new( - :path => oexe, - :source => exe, - :mode => 0755 + + file = Puppet::Type.type(:file).new( + + :path => oexe, + :source => exe, + + :mode => 0755 ) - exec = Puppet::Type.type(:exec).new( - :command => oexe, - :require => Puppet::Resource.new(:file, oexe) + + exec = Puppet::Type.type(:exec).new( + + :command => oexe, + + :require => Puppet::Resource.new(:file, oexe) ) comp = mk_catalog("Testing", file, exec) @@ -196,33 +235,48 @@ class TestExec < Test::Unit::TestCase sh = %x{which sh} File.open(exe, "w") { |f| f.puts "#!#{sh}\necho yup" } - file = Puppet::Type.type(:file).new( - :path => oexe, - :source => exe, - :mode => 755 + + file = Puppet::Type.type(:file).new( + + :path => oexe, + :source => exe, + + :mode => 755 ) basedir = File.dirname(oexe) - baseobj = Puppet::Type.type(:file).new( - :path => basedir, - :source => exe, - :mode => 755 + + baseobj = Puppet::Type.type(:file).new( + + :path => basedir, + :source => exe, + + :mode => 755 ) - ofile = Puppet::Type.type(:file).new( - :path => exe, - :mode => 755 + + ofile = Puppet::Type.type(:file).new( + + :path => exe, + + :mode => 755 ) - exec = Puppet::Type.type(:exec).new( - :command => oexe, - :path => ENV["PATH"], - :cwd => basedir + + exec = Puppet::Type.type(:exec).new( + + :command => oexe, + :path => ENV["PATH"], + + :cwd => basedir ) - cat = Puppet::Type.type(:exec).new( - :command => "cat %s %s" % [exe, oexe], - :path => ENV["PATH"] + + cat = Puppet::Type.type(:exec).new( + + :command => "cat %s %s" % [exe, oexe], + + :path => ENV["PATH"] ) catalog = mk_catalog(file, baseobj, ofile, exec, cat) @@ -255,9 +309,12 @@ class TestExec < Test::Unit::TestCase exec = nil assert_nothing_raised { + exec = Puppet::Type.type(:exec).new( + :command => "touch %s" % bfile, :onlyif => "test -f %s" % afile, + :path => ENV['PATH'] ) } @@ -276,9 +333,12 @@ class TestExec < Test::Unit::TestCase exec = nil assert_nothing_raised { + exec = Puppet::Type.type(:exec).new( + :command => "touch %s" % bfile, :unless => "test -f %s" % afile, + :path => ENV['PATH'] ) } @@ -359,10 +419,13 @@ class TestExec < Test::Unit::TestCase def test_logoutput exec = nil assert_nothing_raised { + exec = Puppet::Type.type(:exec).new( + :title => "logoutputesting", :path => "/usr/bin:/bin", :command => "echo logoutput is false", + :logoutput => false ) } @@ -390,20 +453,26 @@ class TestExec < Test::Unit::TestCase basedir = tempfile() path = File.join(basedir, "subfile") assert_nothing_raised { + exec = Puppet::Type.type(:exec).new( + :title => "mkdir", :path => "/usr/bin:/bin", :creates => basedir, + :command => "mkdir %s; touch %s" % [basedir, path] ) } assert_nothing_raised { + file = Puppet::Type.type(:file).new( + :path => basedir, :recurse => true, :mode => "755", + :require => Puppet::Resource.new("exec", "mkdir") ) } @@ -440,18 +509,24 @@ class TestExec < Test::Unit::TestCase file = tempfile() assert_nothing_raised { + exec1 = Puppet::Type.type(:exec).new( + :title => "one", :path => ENV["PATH"], + :command => "mkdir #{dir}" ) } assert_nothing_raised("Could not create exec w/out existing cwd") { + exec2 = Puppet::Type.type(:exec).new( + :title => "two", :path => ENV["PATH"], :command => "touch #{file}", + :cwd => dir ) } @@ -482,8 +557,11 @@ class TestExec < Test::Unit::TestCase test = "test -f #{file}" assert_nothing_raised { + exec = Puppet::Type.type(:exec).new( + :path => ENV["PATH"], + :command => "touch #{file}" ) } @@ -519,11 +597,14 @@ class TestExec < Test::Unit::TestCase def test_missing_checks_cause_failures # Solaris's sh exits with 1 here instead of 127 return if Facter.value(:operatingsystem) == "Solaris" - exec = Puppet::Type.type(:exec).new( - :command => "echo true", - :path => ENV["PATH"], - :onlyif => "/bin/nosuchthingexists" - ) + + exec = Puppet::Type.type(:exec).new( + + :command => "echo true", + :path => ENV["PATH"], + + :onlyif => "/bin/nosuchthingexists" + ) assert_raise(ArgumentError, "Missing command did not raise error") { exec.run("/bin/nosuchthingexists") @@ -531,9 +612,12 @@ class TestExec < Test::Unit::TestCase end def test_envparam + exec = Puppet::Type.newexec( + :command => "echo $envtest", :path => ENV["PATH"], + :env => "envtest=yayness" ) @@ -550,11 +634,11 @@ class TestExec < Test::Unit::TestCase assert_nothing_raised do exec[:env] = "envtest=a list of things and stuff" - end + end - output = status = nil - assert_nothing_raised { - output, status = exec.run('echo "$envtest"') + output = status = nil + assert_nothing_raised { + output, status = exec.run('echo "$envtest"') } assert_equal("a list of things\nand stuff\n", output) @@ -571,9 +655,12 @@ and stuff" end def test_environmentparam + exec = Puppet::Type.newexec( + :command => "echo $environmenttest", :path => ENV["PATH"], + :environment => "environmenttest=yayness" ) @@ -590,11 +677,11 @@ and stuff" assert_nothing_raised do exec[:environment] = "environmenttest=a list of things and stuff" - end + end - output = status = nil - assert_nothing_raised { - output, status = exec.run('echo "$environmenttest"') + output = status = nil + assert_nothing_raised { + output, status = exec.run('echo "$environmenttest"') } assert_equal("a list of things\nand stuff\n", output) @@ -629,8 +716,11 @@ and stuff" if Process.uid == 0 user = "nosuchuser" assert_nothing_raised("Could not create exec with non-existent user") do + exec = Puppet::Type.type(:exec).new( + :command => "/bin/echo yay", + :user => user ) end @@ -639,8 +729,11 @@ and stuff" # Now try the group group = "nosuchgroup" assert_nothing_raised("Could not create exec with non-existent user") do + exec = Puppet::Type.type(:exec).new( + :command => "/bin/echo yay", + :group => group ) end @@ -651,18 +744,15 @@ and stuff" path = %w{/usr/bin /usr/sbin /sbin} exec = nil assert_nothing_raised("Could not use an array for the path") do - exec = Puppet::Type.type(:exec).new(:command => "echo yay", - :path => path) + exec = Puppet::Type.type(:exec).new(:command => "echo yay", :path => path) end assert_equal(path, exec[:path], "array-based path did not match") assert_nothing_raised("Could not use a string for the path") do - exec = Puppet::Type.type(:exec).new(:command => "echo yay", - :path => path.join(":")) + exec = Puppet::Type.type(:exec).new(:command => "echo yay", :path => path.join(":")) end assert_equal(path, exec[:path], "string-based path did not match") assert_nothing_raised("Could not use a colon-separated strings in an array for the path") do - exec = Puppet::Type.type(:exec).new(:command => "echo yay", - :path => ["/usr/bin", "/usr/sbin:/sbin"]) + exec = Puppet::Type.type(:exec).new(:command => "echo yay", :path => ["/usr/bin", "/usr/sbin:/sbin"]) end assert_equal(path, exec[:path], "colon-separated array path did not match") end @@ -670,10 +760,13 @@ and stuff" def test_checks_apply_to_refresh file = tempfile() maker = tempfile() - exec = Puppet::Type.type(:exec).new( - :title => "maker", - :command => "touch #{maker}", - :path => ENV["PATH"] + + exec = Puppet::Type.type(:exec).new( + + :title => "maker", + :command => "touch #{maker}", + + :path => ENV["PATH"] ) # Make sure it runs normally @@ -709,10 +802,13 @@ and stuff" def test_explicit_refresh refresher = tempfile() maker = tempfile() - exec = Puppet::Type.type(:exec).new( - :title => "maker", - :command => "touch #{maker}", - :path => ENV["PATH"] + + exec = Puppet::Type.type(:exec).new( + + :title => "maker", + :command => "touch #{maker}", + + :path => ENV["PATH"] ) # Call refresh normally diff --git a/test/ral/type/file.rb b/test/ral/type/file.rb index 5416d8ceb..24aab1fd6 100755 --- a/test/ral/type/file.rb +++ b/test/ral/type/file.rb @@ -119,10 +119,13 @@ class TestFile < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :path => path, :owner => user.name, :ensure => "file", + :mode => "755" ) } @@ -149,8 +152,11 @@ class TestFile < Test::Unit::TestCase obj = nil assert_nothing_raised { - obj = Puppet::Type.type(:file).new( + + obj = Puppet::Type.type(:file).new( + :title => link, + :owner => user.name ) } @@ -280,8 +286,11 @@ class TestFile < Test::Unit::TestCase assert(File.stat(file).uid > 120000, "eh?") user = nonrootuser - obj = Puppet::Type.newfile( + + obj = Puppet::Type.newfile( + :path => file, + :owner => user.name ) @@ -298,8 +307,11 @@ class TestFile < Test::Unit::TestCase %w{a b c d}.collect { |name| tempfile() + name.to_s }.each { |path| file =nil assert_nothing_raised() { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :name => path, + :ensure => "file" ) } @@ -316,13 +328,15 @@ class TestFile < Test::Unit::TestCase %w{a b c d}.collect { |name| "#{basedir}/%s" % name }.each { |path| file = nil assert_nothing_raised() { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :name => path, + :ensure => "directory" ) } - assert(! FileTest.directory?(path), "Directory %s already exists" % - [path]) + assert(! FileTest.directory?(path), "Directory %s already exists" % [path]) assert_events([:directory_created], file) assert_events([], file) assert(FileTest.directory?(path)) @@ -357,9 +371,12 @@ class TestFile < Test::Unit::TestCase initstorage assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + param => path, :recurse => true, + :checksum => "md5" ) } @@ -383,8 +400,11 @@ class TestFile < Test::Unit::TestCase # Verify it retrieves files of type directory assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :name => tmpdir(), + :check => :type ) } @@ -393,8 +413,11 @@ class TestFile < Test::Unit::TestCase # And then check files assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :name => tempfile(), + :ensure => "file" ) } @@ -419,9 +442,12 @@ class TestFile < Test::Unit::TestCase file = nil dirobj = nil assert_nothing_raised("Could not make file object") { - dirobj = Puppet::Type.type(:file).new( + + dirobj = Puppet::Type.type(:file).new( + :path => dir, :recurse => true, + :check => %w{mode owner group} ) } @@ -444,13 +470,19 @@ class TestFile < Test::Unit::TestCase basedir = tempfile() subfile = File.join(basedir, "subfile") - baseobj = Puppet::Type.type(:file).new( + + baseobj = Puppet::Type.type(:file).new( + :name => basedir, + :ensure => "directory" ) - subobj = Puppet::Type.type(:file).new( + + subobj = Puppet::Type.type(:file).new( + :name => subfile, + :ensure => "file" ) catalog = mk_catalog(baseobj, subobj) @@ -468,9 +500,12 @@ class TestFile < Test::Unit::TestCase subpath = File.join(path, "this", "is", "a", "dir") file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :name => subpath, :ensure => "directory", + :recurse => true ) } @@ -490,10 +525,13 @@ class TestFile < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :name => dest, :checksum => "md5", :content => "This is some content", + :backup => false ) } @@ -511,9 +549,12 @@ class TestFile < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :name => dest, :checksum => "md5", + :ensure => "file" ) } @@ -530,9 +571,12 @@ class TestFile < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :title => "fileness", :path => path, + :content => "this is some content" ) } @@ -546,8 +590,11 @@ class TestFile < Test::Unit::TestCase def test_missinggroup file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :path => tempfile(), + :group => "fakegroup" ) } @@ -557,21 +604,21 @@ class TestFile < Test::Unit::TestCase def test_modecreation path = tempfile() - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :path => path, :ensure => "file", + :mode => "0777" ) - assert_equal(0777, file.should(:mode), - "Mode did not get set correctly") + assert_equal(0777, file.should(:mode), "Mode did not get set correctly") assert_apply(file) - assert_equal(0777, File.stat(path).mode & 007777, - "file mode is incorrect") + assert_equal(0777, File.stat(path).mode & 007777, "file mode is incorrect") File.unlink(path) file[:ensure] = "directory" assert_apply(file) - assert_equal(0777, File.stat(path).mode & 007777, - "directory mode is incorrect") + assert_equal(0777, File.stat(path).mode & 007777, "directory mode is incorrect") end # If both 'ensure' and 'content' are used, make sure that all of the other @@ -581,10 +628,13 @@ class TestFile < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :path => path, :ensure => "file", :content => "some text\n", + :mode => 0755 ) } @@ -602,9 +652,12 @@ class TestFile < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :ensure => path, :path => link, + :backup => false ) } @@ -623,8 +676,11 @@ class TestFile < Test::Unit::TestCase dest = File.join(dir, "another space") File.open(source, "w") { |f| f.puts :yay } - obj = Puppet::Type.type(:file).new( + + obj = Puppet::Type.type(:file).new( + :path => dest, + :source => source ) assert(obj, "Did not create file") @@ -656,15 +712,21 @@ class TestFile < Test::Unit::TestCase home = nil ogroup = nil assert_nothing_raised { - user = Puppet::Type.type(:user).new( + + user = Puppet::Type.type(:user).new( + :name => "pptestu", :home => file, + :gid => "pptestg" ) - home = Puppet::Type.type(:file).new( + + home = Puppet::Type.type(:file).new( + :path => file, :owner => "pptestu", :group => "pptestg", + :ensure => "directory" ) group = Puppet::Type.type(:group).new( @@ -809,12 +871,14 @@ class TestFile < Test::Unit::TestCase else current = stat.send(should) end - assert_equal(sval, current, - "Attr %s was not correct %s" % [should, msg]) + assert_equal(sval, current, "Attr %s was not correct %s" % [should, msg]) end end - file = Puppet::Type.newfile(:path => path, :owner => user.name, + + file = Puppet::Type.newfile( + :path => path, :owner => user.name, + :group => group.name, :mode => 0640, :backup => false) {:source => source, :content => "some content"}.each do |attr, value| file[attr] = value diff --git a/test/ral/type/file/target.rb b/test/ral/type/file/target.rb index 89792c4b6..6b252d28f 100755 --- a/test/ral/type/file/target.rb +++ b/test/ral/type/file/target.rb @@ -24,9 +24,12 @@ class TestFileTarget < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :title => "somethingelse", :ensure => path, + :path => link ) } @@ -52,9 +55,12 @@ class TestFileTarget < Test::Unit::TestCase system("mkdir -p %s" % subdir) system("touch %s" % file) - link = Puppet::Type.type(:file).new( + + link = Puppet::Type.type(:file).new( + :ensure => source, :path => path, + :recurse => true ) @@ -96,9 +102,12 @@ class TestFileTarget < Test::Unit::TestCase link = nil assert_nothing_raised { - link = Puppet::Type.type(:file).new( + + link = Puppet::Type.type(:file).new( + :ensure => source, :path => dest, + :recurse => true ) } @@ -131,8 +140,11 @@ class TestFileTarget < Test::Unit::TestCase link = nil assert_nothing_raised { - link = Puppet::Type.type(:file).new( + + link = Puppet::Type.type(:file).new( + :path => dest, + :ensure => "source" ) } @@ -148,15 +160,21 @@ class TestFileTarget < Test::Unit::TestCase dest = tempfile() resources = [] - resources << Puppet::Type.type(:exec).new( + + resources << Puppet::Type.type(:exec).new( + :command => "mkdir %s; touch %s/file" % [source, source], :title => "yay", + :path => ENV["PATH"] ) - resources << Puppet::Type.type(:file).new( + + resources << Puppet::Type.type(:file).new( + :ensure => source, :path => dest, :recurse => true, + :require => resources[0] ) @@ -175,19 +193,28 @@ class TestFileTarget < Test::Unit::TestCase prop = obj.send(:property, :target) prop.send(:instance_variable_set, "@should", [:nochange]) - assert(prop.insync?(prop.retrieve), + + assert( + prop.insync?(prop.retrieve), + "Property not in sync with should == :nochange") prop = obj.send(:property, :target) prop.send(:instance_variable_set, "@should", [:notlink]) - assert(prop.insync?(prop.retrieve), + + assert( + prop.insync?(prop.retrieve), + "Property not in sync with should == :nochange") # Lastly, make sure that we don't try to do anything when we're # recursing, since 'ensure' does the work. obj[:recurse] = true prop.should = dest - assert(prop.insync?(prop.retrieve), + + assert( + prop.insync?(prop.retrieve), + "Still out of sync during recursion") end @@ -202,9 +229,12 @@ class TestFileTarget < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :ensure => path, :path => link, + :backup => false ) } @@ -233,14 +263,20 @@ class TestFileTarget < Test::Unit::TestCase File.open(file, "w") { |f| f.puts "yayness" } File.symlink(file, link) - obj = Puppet::Type.type(:file).new( + + obj = Puppet::Type.type(:file).new( + :path => link, + :ensure => "file" ) assert_apply(obj) - assert_equal("yayness\n", File.read(file), + + assert_equal( + "yayness\n", File.read(file), + "Original file got changed") assert_equal("file", File.lstat(link).ftype, "File is still a link") end @@ -264,10 +300,13 @@ class TestFileTarget < Test::Unit::TestCase File.open(sourcefile, "w") { |f| f.puts "source" } File.symlink(file, link) - obj = Puppet::Type.type(:file).new( + + obj = Puppet::Type.type(:file).new( + :path => dirs["target"], :ensure => :file, :source => dirs["source"], + :recurse => true ) config = mk_catalog obj @@ -281,7 +320,10 @@ class TestFileTarget < Test::Unit::TestCase assert_equal(File.read(sourcefile), File.read(newfile), "File did not get copied correctly.") - assert_equal("other\n", File.read(file), + + assert_equal( + "other\n", File.read(file), + "Original file got changed") assert_equal("file", File.lstat(link).ftype, "File is still a link") end @@ -294,8 +336,11 @@ class TestFileTarget < Test::Unit::TestCase File.open(dest, "w") { |f| f.puts "boo" } File.open(otherdest, "w") { |f| f.puts "yay" } - obj = Puppet::Type.type(:file).new( + + obj = Puppet::Type.type(:file).new( + :path => link, + :ensure => otherdest ) diff --git a/test/ral/type/fileignoresource.rb b/test/ral/type/fileignoresource.rb index ad68f703c..f158ac20d 100755 --- a/test/ral/type/fileignoresource.rb +++ b/test/ral/type/fileignoresource.rb @@ -56,23 +56,32 @@ class TestFileIgnoreSources < Test::Unit::TestCase #create source files - File.open(File.join(frompath,sourcefile1), - File::WRONLY|File::CREAT|File::APPEND) { |of| - of.puts "yayness" + + File.open( + File.join(frompath,sourcefile1), + + File::WRONLY|File::CREAT|File::APPEND) { |of| + of.puts "yayness" } - File.open(File.join(frompath,sourcefile2), - File::WRONLY|File::CREAT|File::APPEND) { |of| - of.puts "even yayer" + + File.open( + File.join(frompath,sourcefile2), + + File::WRONLY|File::CREAT|File::APPEND) { |of| + of.puts "even yayer" } #makes Puppet file Object assert_nothing_raised { + tofile = Puppet::Type.type(:file).new( + :name => topath, :source => frompath, :recurse => true, + :ignore => "sourcefile2" ) } @@ -119,24 +128,33 @@ class TestFileIgnoreSources < Test::Unit::TestCase #create source files dir.each { |dir| - File.open(File.join(dir,sourcefile1), - File::WRONLY|File::CREAT|File::APPEND) { |of| + + File.open( + File.join(dir,sourcefile1), + + File::WRONLY|File::CREAT|File::APPEND) { |of| of.puts "yayness" } - File.open(File.join(dir,sourcefile2), - File::WRONLY|File::CREAT|File::APPEND) { |of| - of.puts "even yayer" + + File.open( + File.join(dir,sourcefile2), + + File::WRONLY|File::CREAT|File::APPEND) { |of| + of.puts "even yayer" } } #makes Puppet file Object assert_nothing_raised { + tofile = Puppet::Type.type(:file).new( + :name => topath, :source => frompath, :recurse => true, + :ignore => "*2" ) } @@ -190,14 +208,20 @@ class TestFileIgnoreSources < Test::Unit::TestCase sourcedir.each { |dir| - File.open(File.join(dir,sourcefile1), - File::WRONLY|File::CREAT|File::APPEND) { |of| + + File.open( + File.join(dir,sourcefile1), + + File::WRONLY|File::CREAT|File::APPEND) { |of| of.puts "yayness" } - File.open(File.join(dir,sourcefile2), - File::WRONLY|File::CREAT|File::APPEND) { |of| - of.puts "even yayer" + + File.open( + File.join(dir,sourcefile2), + + File::WRONLY|File::CREAT|File::APPEND) { |of| + of.puts "even yayer" } } @@ -205,12 +229,15 @@ class TestFileIgnoreSources < Test::Unit::TestCase #makes Puppet file Object assert_nothing_raised { + tofile = Puppet::Type.type(:file).new( + :name => topath, :source => frompath, :recurse => true, + :ignore => ["*2", "an*"] - # :ignore => ["*2", "an*", "nomatch"] + # :ignore => ["*2", "an*", "nomatch"] ) } diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb index 408439d45..0ca09d2ff 100755 --- a/test/ral/type/filesources.rb +++ b/test/ral/type/filesources.rb @@ -13,7 +13,7 @@ class TestFileSources < Test::Unit::TestCase include PuppetTest::FileTesting def setup super - if defined? @port + if defined?(@port) @port += 1 else @port = 12345 @@ -59,10 +59,13 @@ class TestFileSources < Test::Unit::TestCase tofile = nil trans = nil - tofile = Puppet::Type.type(:file).new( + + tofile = Puppet::Type.type(:file).new( + :path => todir, :recurse => true, :backup => false, + :source => fromdir ) catalog = mk_catalog(tofile) @@ -192,10 +195,13 @@ class TestFileSources < Test::Unit::TestCase File.open(file1, "w") { |f| f.puts "yay" } rootobj = nil assert_nothing_raised { - rootobj = Puppet::Type.type(:file).new( + + rootobj = Puppet::Type.type(:file).new( + :name => basedir, :recurse => true, :check => %w{type owner}, + :mode => 0755 ) } @@ -240,8 +246,11 @@ class TestFileSources < Test::Unit::TestCase serverpid = nil assert_nothing_raised("Could not start on port %s" % @port) { - server = Puppet::Network::HTTPServer::WEBrick.new( + + server = Puppet::Network::HTTPServer::WEBrick.new( + :Port => @port, + :Handlers => { :CA => {}, # so that certs autogenerate :FileServer => { @@ -264,8 +273,11 @@ class TestFileSources < Test::Unit::TestCase sleep(1) name = File.join(tmpdir(), "nosourcefile") - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :source => "puppet://localhost/noexist/file", + :name => name ) @@ -291,8 +303,11 @@ class TestFileSources < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :name => to, + :source => files ) } @@ -316,9 +331,12 @@ class TestFileSources < Test::Unit::TestCase file = nil assert_nothing_raised { - file = Puppet::Type.type(:file).new( + + file = Puppet::Type.type(:file).new( + :name => dest, :ensure => "file", + :source => source ) } @@ -357,9 +375,12 @@ class TestFileSources < Test::Unit::TestCase # are. def test_replace dest = tempfile() - file = Puppet::Type.newfile( + + file = Puppet::Type.newfile( + :path => dest, :content => "foobar", + :recurse => true ) @@ -373,15 +394,13 @@ class TestFileSources < Test::Unit::TestCase assert_apply(file) # Make sure it doesn't change. - assert_equal("yayness\n", File.read(dest), - "File got replaced when :replace was false") + assert_equal("yayness\n", File.read(dest), "File got replaced when :replace was false") file[:replace] = true assert_apply(file) # Make sure it changes. - assert_equal("foobar", File.read(dest), - "File was not replaced when :replace was true") + assert_equal("foobar", File.read(dest), "File was not replaced when :replace was true") end def test_sourceselect @@ -406,7 +425,10 @@ class TestFileSources < Test::Unit::TestCase } end - obj = Puppet::Type.newfile(:path => dest, :recurse => true, + + obj = Puppet::Type.newfile( + :path => dest, :recurse => true, + :source => sources) assert_equal(:first, obj[:sourceselect], "sourceselect has the wrong default") diff --git a/test/ral/type/host.rb b/test/ral/type/host.rb index 308e84bc0..81a4c0876 100755 --- a/test/ral/type/host.rb +++ b/test/ral/type/host.rb @@ -33,7 +33,7 @@ class TestHost < Test::Unit::TestCase end def mkhost - if defined? @hcount + if defined?(@hcount) @hcount += 1 else @hcount = 1 @@ -43,10 +43,13 @@ class TestHost < Test::Unit::TestCase host = nil assert_nothing_raised { - host = Puppet::Type.type(:host).new( + + host = Puppet::Type.type(:host).new( + :name => "fakehost%s" % @hcount, :ip => "192.168.27.%s" % @hcount, :alias => "alias%s" % @hcount, + :catalog => @catalog ) } @@ -68,8 +71,11 @@ class TestHost < Test::Unit::TestCase host = nil assert_nothing_raised { - host = Puppet::Type.type(:host).new( + + host = Puppet::Type.type(:host).new( + :name => "culain", + :ip => "192.168.0.3" ) } diff --git a/test/ral/type/port.rb b/test/ral/type/port.rb index ae5d89c2d..fa57cf55f 100755 --- a/test/ral/type/port.rb +++ b/test/ral/type/port.rb @@ -34,7 +34,7 @@ require 'puppettest' # def mkport # port = nil # -# if defined? @pcount +# if defined?(@pcount) # @pcount += 1 # else # @pcount = 1 diff --git a/test/ral/type/sshkey.rb b/test/ral/type/sshkey.rb index b68c14b34..a774af393 100755 --- a/test/ral/type/sshkey.rb +++ b/test/ral/type/sshkey.rb @@ -40,7 +40,7 @@ class TestSSHKey < Test::Unit::TestCase def mkkey key = nil - if defined? @kcount + if defined?(@kcount) @kcount += 1 else @kcount = 1 @@ -48,11 +48,14 @@ class TestSSHKey < Test::Unit::TestCase @catalog ||= mk_catalog - key = @sshkeytype.new( + + key = @sshkeytype.new( + :name => "host%s.madstop.com" % @kcount, :key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount, :type => "ssh-dss", :alias => ["192.168.0.%s" % @kcount], + :catalog => @catalog ) diff --git a/test/ral/type/user.rb b/test/ral/type/user.rb index 797fa0139..8e1bc9359 100755 --- a/test/ral/type/user.rb +++ b/test/ral/type/user.rb @@ -27,7 +27,7 @@ class TestUser < Test::Unit::TestCase end def exists? - if defined? @ensure and @ensure == :present + if defined?(@ensure) and @ensure == :present true else false @@ -64,11 +64,14 @@ class TestUser < Test::Unit::TestCase def mkuser(name) user = nil assert_nothing_raised { - user = Puppet::Type.type(:user).new( + + user = Puppet::Type.type(:user).new( + :name => name, :comment => "Puppet Testing User", :gid => Puppet::Util::SUIDManager.gid, :shell => findshell(), + :home => "/home/%s" % name ) } @@ -86,15 +89,21 @@ class TestUser < Test::Unit::TestCase home = nil ogroup = nil assert_nothing_raised { - user = Puppet::Type.type(:user).new( + + user = Puppet::Type.type(:user).new( + :name => "pptestu", :home => file, :gid => "pptestg", + :groups => "yayness" ) - home = Puppet::Type.type(:file).new( + + home = Puppet::Type.type(:file).new( + :path => file, :owner => "pptestu", + :ensure => "directory" ) group = Puppet::Type.type(:group).new( diff --git a/test/ral/type/yumrepo.rb b/test/ral/type/yumrepo.rb index e1ac53820..fcfd73f99 100755 --- a/test/ral/type/yumrepo.rb +++ b/test/ral/type/yumrepo.rb @@ -67,9 +67,12 @@ class TestYumRepo < Test::Unit::TestCase def test_absent copy_datafiles baseurl = 'http://example.com/' - devel = make_repo("development", - { :mirrorlist => 'absent', - :baseurl => baseurl }) + + devel = make_repo( + "development", + { :mirrorlist => 'absent', + + :baseurl => baseurl }) devel.retrieve assert_apply(devel) inifile = Puppet::Type.type(:yumrepo).read() diff --git a/test/ral/type/zone.rb b/test/ral/type/zone.rb index a784b8bcf..eaf850f59 100755 --- a/test/ral/type/zone.rb +++ b/test/ral/type/zone.rb @@ -21,9 +21,12 @@ class TestZone < PuppetTest::TestCase File.chmod(0700, base) root = File.join(base, "zonebase") assert_nothing_raised { + zone = Puppet::Type.type(:zone).new( + :name => name, :path => root, + :ensure => "configured" # don't want to install zones automatically ) } @@ -111,9 +114,11 @@ class TestZone < PuppetTest::TestCase methods.each do |m| Puppet::Type.type(:zone).suitableprovider.each do |prov| - assert(prov.method_defined?(m), - "Zone provider %s does not define method %s" % - [prov.name, m]) + + assert( + prov.method_defined?(m), + + "Zone provider %s does not define method %s" % [prov.name, m]) end end @@ -130,12 +135,18 @@ class TestZone < PuppetTest::TestCase property = zone.property(:inherit) assert(zone, "Did not get 'inherit' property") - assert_equal("add inherit-pkg-dir\nset dir=/usr\nend", property.configtext, + + assert_equal( + "add inherit-pkg-dir\nset dir=/usr\nend", property.configtext, + "Got incorrect config text") zone.provider.inherit = "/usr" - assert_equal("", property.configtext, + + assert_equal( + "", property.configtext, + "Got incorrect config text") # Now we want multiple directories @@ -149,7 +160,10 @@ add inherit-pkg-dir set dir=/sbin end" - assert_equal(text, property.configtext, + + assert_equal( + text, property.configtext, + "Got incorrect config text") zone.provider.inherit = %w{/usr /sbin /lib} @@ -157,7 +171,10 @@ end" text = "remove inherit-pkg-dir dir=/lib" - assert_equal(text, property.configtext, + + assert_equal( + text, property.configtext, + "Got incorrect config text") end end @@ -230,13 +247,13 @@ set address=#{ip} set physical=bge0 end } - end + end - assert_equal(0, $?, "Did not successfully create zone") + assert_equal(0, $?, "Did not successfully create zone") - hash = nil - assert_nothing_raised { - hash = zone.provider.send(:getconfig) + hash = nil + assert_nothing_raised { + hash = zone.provider.send(:getconfig) } zone[:check] = [:inherit, :autoboot] @@ -247,14 +264,23 @@ end end # And make sure it gets set correctly. - assert_equal(%w{/sbin /usr /opt/csw /lib /platform}.sort, + + assert_equal( + %w{/sbin /usr /opt/csw /lib /platform}.sort, + values[:inherit].sort, "Inherited dirs did not get collected correctly." ) - assert_equal(["#{interface}:#{ip}"], values[:ip], + + assert_equal( + ["#{interface}:#{ip}"], values[:ip], + "IP addresses did not get collected correctly.") - assert_equal(:true, values[:autoboot], + + assert_equal( + :true, values[:autoboot], + "Autoboot did not get collected correctly.") end @@ -280,7 +306,10 @@ end assert(zone.insync?(zone.retrieve), "Zone is not insync") - assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /dir: \/sbin/, + + assert( + %x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /dir: \/sbin/, + "sbin was not added") # And then remove it. @@ -291,7 +320,10 @@ end assert(zone.insync?(zone.retrieve), "Zone is not insync") - assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} !~ /dir: \/sbin/, + + assert( + %x{/usr/sbin/zonecfg -z #{zone[:name]} info} !~ /dir: \/sbin/, + "sbin was not removed") # Now add an ip adddress. Fortunately (or not), zonecfg doesn't verify @@ -302,18 +334,19 @@ end assert_apply(zone) assert(zone.insync?(zone.retrieve), "Zone is not in sync") - assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /192.168.0.1/, + + assert( + %x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /192.168.0.1/, + "ip was not added") zone[:ip] = ["hme1:192.168.0.2", "hme0:192.168.0.1"] assert_apply(zone) assert(zone.insync?(zone.retrieve), "Zone is not in sync") - assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /192.168.0.2/, - "ip was not added") + assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} =~ /192.168.0.2/, "ip was not added") zone[:ip] = ["hme1:192.168.0.2"] assert_apply(zone) zone.retrieve - assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} !~ /192.168.0.1/, - "ip was not removed") + assert(%x{/usr/sbin/zonecfg -z #{zone[:name]} info} !~ /192.168.0.1/, "ip was not removed") end # Test creating and removing a zone, but only up to the configured property, @@ -345,7 +378,7 @@ end currentvalues = zone.retrieve assert_equal(:absent, currentvalues[zone.property(:ensure)], - "Zone is not absent") + "Zone is not absent") end # Just go through each method linearly and make sure it works. @@ -377,9 +410,7 @@ end assert_nothing_raised { current_values = zone.retrieve } - assert_equal(property, current_values[zone.property(:ensure)], - "Method %s did not correctly set property %s" % - [method, property]) + assert_equal(property, current_values[zone.property(:ensure)], "Method %s did not correctly set property %s" % [method, property]) end end @@ -412,7 +443,7 @@ end currentvalues = zone.retrieve assert_equal(:absent, currentvalues[zone.property(:ensure)], - "Zone is not absent") + "Zone is not absent") end end |
