summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/certmgr/ca.rb4
-rwxr-xr-xtest/certmgr/certmgr.rb15
-rwxr-xr-xtest/certmgr/inventory.rb18
-rwxr-xr-xtest/certmgr/support.rb11
-rwxr-xr-xtest/language/ast.rb5
-rwxr-xr-xtest/language/functions.rb71
-rwxr-xr-xtest/language/parser.rb9
-rwxr-xr-xtest/language/scope.rb105
-rwxr-xr-xtest/language/snippets.rb26
-rwxr-xr-xtest/language/transportable.rb5
-rwxr-xr-xtest/lib/puppettest.rb41
-rw-r--r--test/lib/puppettest/fakes.rb3
-rw-r--r--test/lib/puppettest/filetesting.rb25
-rw-r--r--test/lib/puppettest/parsertesting.rb144
-rw-r--r--test/lib/puppettest/railstesting.rb7
-rw-r--r--test/lib/puppettest/resourcetesting.rb10
-rw-r--r--test/lib/puppettest/servertest.rb7
-rw-r--r--test/lib/puppettest/support/utils.rb2
-rwxr-xr-xtest/network/authconfig.rb20
-rwxr-xr-xtest/network/authorization.rb8
-rwxr-xr-xtest/network/authstore.rb130
-rwxr-xr-xtest/network/client/ca.rb6
-rwxr-xr-xtest/network/handler/ca.rb5
-rwxr-xr-xtest/network/handler/fileserver.rb256
-rwxr-xr-xtest/network/rights.rb5
-rwxr-xr-xtest/network/server/webrick.rb20
-rwxr-xr-xtest/network/xmlrpc/processor.rb3
-rwxr-xr-xtest/network/xmlrpc/server.rb3
-rwxr-xr-xtest/network/xmlrpc/webrick_servlet.rb5
-rwxr-xr-xtest/other/relationships.rb18
-rwxr-xr-xtest/other/report.rb8
-rwxr-xr-xtest/other/transactions.rb33
-rwxr-xr-xtest/puppet/defaults.rb3
-rwxr-xr-xtest/puppet/tc_suidmanager.rb21
-rwxr-xr-xtest/rails/railsparameter.rb18
-rwxr-xr-xtest/ral/manager/attributes.rb27
-rwxr-xr-xtest/ral/manager/provider.rb3
-rwxr-xr-xtest/ral/manager/type.rb81
-rwxr-xr-xtest/ral/providers/cron/crontab.rb60
-rwxr-xr-xtest/ral/providers/group.rb3
-rwxr-xr-xtest/ral/providers/host/parsed.rb17
-rwxr-xr-xtest/ral/providers/mailalias/aliases.rb2
-rwxr-xr-xtest/ral/providers/package.rb9
-rwxr-xr-xtest/ral/providers/package/aptitude.rb78
-rwxr-xr-xtest/ral/providers/package/aptrpm.rb76
-rwxr-xr-xtest/ral/providers/parsedfile.rb58
-rwxr-xr-xtest/ral/providers/provider.rb106
-rwxr-xr-xtest/ral/providers/service/base.rb10
-rwxr-xr-xtest/ral/providers/sshkey/parsed.rb7
-rwxr-xr-xtest/ral/providers/user.rb68
-rwxr-xr-xtest/ral/providers/user/useradd.rb65
-rwxr-xr-xtest/ral/type/cron.rb73
-rwxr-xr-xtest/ral/type/exec.rb206
-rwxr-xr-xtest/ral/type/file.rb130
-rwxr-xr-xtest/ral/type/file/target.rb75
-rwxr-xr-xtest/ral/type/fileignoresource.rb61
-rwxr-xr-xtest/ral/type/filesources.rb48
-rwxr-xr-xtest/ral/type/host.rb12
-rwxr-xr-xtest/ral/type/port.rb2
-rwxr-xr-xtest/ral/type/sshkey.rb7
-rwxr-xr-xtest/ral/type/user.rb17
-rwxr-xr-xtest/ral/type/yumrepo.rb9
-rwxr-xr-xtest/ral/type/zone.rb85
-rwxr-xr-xtest/util/classgen.rb39
-rwxr-xr-xtest/util/fileparsing.rb164
-rwxr-xr-xtest/util/inifile.rb43
-rwxr-xr-xtest/util/log.rb27
-rwxr-xr-xtest/util/package.rb3
-rwxr-xr-xtest/util/settings.rb146
-rwxr-xr-xtest/util/storage.rb5
-rwxr-xr-xtest/util/subclass_loader.rb11
-rwxr-xr-xtest/util/utiltest.rb59
72 files changed, 1946 insertions, 1016 deletions
diff --git a/test/certmgr/ca.rb b/test/certmgr/ca.rb
index 5b7944b46..969bd935f 100755
--- a/test/certmgr/ca.rb
+++ b/test/certmgr/ca.rb
@@ -12,8 +12,8 @@ class TestCA < Test::Unit::TestCase
include PuppetTest
def setup
- super
- Puppet::Util::SUIDManager.stubs(:asuser).yields
+ super
+ Puppet::Util::SUIDManager.stubs(:asuser).yields
end
def hosts
diff --git a/test/certmgr/certmgr.rb b/test/certmgr/certmgr.rb
index de63fc399..ab4372c5b 100755
--- a/test/certmgr/certmgr.rb
+++ b/test/certmgr/certmgr.rb
@@ -23,8 +23,11 @@ class TestCertMgr < Test::Unit::TestCase
cert = nil
name = "testing"
newcert = proc {
- Puppet::SSLCertificates::Certificate.new(
+
+ Puppet::SSLCertificates::Certificate.new(
+
:name => name,
+
:selfsign => true
)
}
@@ -67,9 +70,12 @@ class TestCertMgr < Test::Unit::TestCase
name = "testing"
keyfile = mkPassFile
assert_nothing_raised {
- cert = Puppet::SSLCertificates::Certificate.new(
+
+ cert = Puppet::SSLCertificates::Certificate.new(
+
:name => name,
:selfsign => true,
+
:capass => keyfile
)
}
@@ -120,7 +126,9 @@ class TestCertMgr < Test::Unit::TestCase
cert = nil
assert_nothing_raised {
- cert = Puppet::SSLCertificates::Certificate.new(
+
+ cert = Puppet::SSLCertificates::Certificate.new(
+
:name => "signedcertest",
:property => "TN",
:city => "Nashville",
@@ -128,6 +136,7 @@ class TestCertMgr < Test::Unit::TestCase
:email => "luke@madstop.com",
:org => "Puppet",
:ou => "Development",
+
:encrypt => mkPassFile()
)
diff --git a/test/certmgr/inventory.rb b/test/certmgr/inventory.rb
index 9c1e19ffe..a0617525d 100755
--- a/test/certmgr/inventory.rb
+++ b/test/certmgr/inventory.rb
@@ -13,8 +13,8 @@ class TestCertInventory < Test::Unit::TestCase
Inventory = Puppet::SSLCertificates::Inventory
def setup
- super
- Puppet::Util::SUIDManager.stubs(:asuser).yields
+ super
+ Puppet::Util::SUIDManager.stubs(:asuser).yields
end
def test_format
@@ -25,9 +25,12 @@ class TestCertInventory < Test::Unit::TestCase
format = Inventory.format(cert)
end
- assert(format =~ /^0x0001 \S+ \S+ #{cert.subject}/,
- "Did not create correct format")
- end
+
+ assert(
+ format =~ /^0x0001 \S+ \S+ #{cert.subject}/,
+
+ "Did not create correct format")
+ end
def test_init
# First create a couple of certificates
@@ -42,8 +45,7 @@ class TestCertInventory < Test::Unit::TestCase
end
[cert1, cert2].each do |cert|
- assert(init.include?(cert.subject.to_s),
- "Did not catch %s" % cert.subject.to_s)
+ assert(init.include?(cert.subject.to_s), "Did not catch %s" % cert.subject.to_s)
end
end
@@ -58,7 +60,7 @@ class TestCertInventory < Test::Unit::TestCase
end
Puppet::Util::Settings.any_instance.stubs(:write)
Puppet::Util::Settings.any_instance.expects(:write).
- with(:cert_inventory, 'a').yields(file)
+ with(:cert_inventory, 'a').yields(file)
Puppet::SSLCertificates::Inventory.add(cert)
end
diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb
index d418c6771..645d43c42 100755
--- a/test/certmgr/support.rb
+++ b/test/certmgr/support.rb
@@ -25,11 +25,9 @@ class TestCertSupport < Test::Unit::TestCase
# Yay, metaprogramming
def test_keytype
[:key, :csr, :cert, :ca_cert].each do |name|
- assert(Puppet::SSLCertificates::Support.method_defined?(name),
- "No retrieval method for %s" % name)
+ assert(Puppet::SSLCertificates::Support.method_defined?(name), "No retrieval method for %s" % name)
maker = "mk_%s" % name
- assert(Puppet::SSLCertificates::Support.method_defined?(maker),
- "No maker method for %s" % name)
+ assert(Puppet::SSLCertificates::Support.method_defined?(maker), "No maker method for %s" % name)
end
end
@@ -43,7 +41,10 @@ class TestCertSupport < Test::Unit::TestCase
assert_logged(:info, /Creating a new SSL/, "Did not log about new key")
keys.each do |file|
- assert(FileTest.exists?(Puppet[file]),
+
+ assert(
+ FileTest.exists?(Puppet[file]),
+
"Did not create %s key file" % file)
end
diff --git a/test/language/ast.rb b/test/language/ast.rb
index a4d4d8773..d11c87f6d 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -23,9 +23,12 @@ class TestAST < Test::Unit::TestCase
astelse = AST::Else.new(:statements => fakeelse)
}
assert_nothing_raised {
- astif = AST::IfStatement.new(
+
+ astif = AST::IfStatement.new(
+
:test => faketest,
:statements => fakeif,
+
:else => astelse
)
}
diff --git a/test/language/functions.rb b/test/language/functions.rb
index 5463cf256..a9d7c1a7f 100755
--- a/test/language/functions.rb
+++ b/test/language/functions.rb
@@ -14,8 +14,11 @@ class TestLangFunctions < Test::Unit::TestCase
def test_functions
Puppet::Node::Environment.stubs(:current).returns nil
assert_nothing_raised do
+
Puppet::Parser::AST::Function.new(
+
:name => "fakefunction",
+
:arguments => AST::ASTArray.new(
:children => [nameobj("avalue")]
)
@@ -23,8 +26,11 @@ class TestLangFunctions < Test::Unit::TestCase
end
assert_raise(Puppet::ParseError) do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "fakefunction",
+
:arguments => AST::ASTArray.new(
:children => [nameobj("avalue")]
)
@@ -40,9 +46,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "fakefunction",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [nameobj("avalue")]
)
@@ -84,12 +93,14 @@ class TestLangFunctions < Test::Unit::TestCase
def test_failfunction
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "fail",
:ftype => :statement,
+
:arguments => AST::ASTArray.new(
- :children => [stringobj("this is a failure"),
- stringobj("and another")]
+ :children => [stringobj("this is a failure"), stringobj("and another")]
)
)
end
@@ -116,12 +127,14 @@ class TestLangFunctions < Test::Unit::TestCase
end
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
- :children => [stringobj("one"),
- stringobj("two")]
+ :children => [stringobj("one"), stringobj("two")]
)
)
end
@@ -142,8 +155,7 @@ class TestLangFunctions < Test::Unit::TestCase
end
# Ensure that we got the output we expected from that evaluation.
- assert_equal("template One\ntemplate \n", scope.lookupvar("output"),
- "Undefined template variables do not raise exceptions")
+ assert_equal("template One\ntemplate \n", scope.lookupvar("output"), "Undefined template variables do not raise exceptions")
# Now, fill in the last variable and make sure the whole thing
# evaluates correctly.
@@ -153,7 +165,10 @@ class TestLangFunctions < Test::Unit::TestCase
ast.evaluate(scope)
end
- assert_equal("template One\ntemplate Two\n", scope.lookupvar("output"),
+
+ assert_equal(
+ "template One\ntemplate Two\n", scope.lookupvar("output"),
+
"Templates were not handled correctly")
end
@@ -167,9 +182,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -188,7 +206,10 @@ class TestLangFunctions < Test::Unit::TestCase
ast.evaluate(scope)
end
- assert_equal("template this is yay\n", scope.lookupvar("output"),
+
+ assert_equal(
+ "template this is yay\n", scope.lookupvar("output"),
+
"Templates were not handled correctly")
end
@@ -203,9 +224,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -225,8 +249,11 @@ class TestLangFunctions < Test::Unit::TestCase
ast.evaluate(scope)
end
- assert_equal("template deprecated value\n", scope.lookupvar("output"),
- "Deprecated template variables were not handled correctly")
+
+ assert_equal(
+ "template deprecated value\n", scope.lookupvar("output"),
+
+ "Deprecated template variables were not handled correctly")
end
# Make sure that problems with kernel method visibility still exist.
@@ -236,9 +263,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -262,9 +292,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -302,7 +335,10 @@ class TestLangFunctions < Test::Unit::TestCase
fileobj = catalog.vertices.find { |r| r.title == file }
assert(fileobj, "File was not in catalog")
- assert_equal("original text\n", fileobj["content"],
+
+ assert_equal(
+ "original text\n", fileobj["content"],
+
"Template did not work")
Puppet[:filetimeout] = -5
@@ -328,9 +364,12 @@ class TestLangFunctions < Test::Unit::TestCase
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => "template",
:ftype => :rvalue,
+
:arguments => AST::ASTArray.new(
:children => [stringobj(template)]
)
@@ -350,8 +389,11 @@ class TestLangFunctions < Test::Unit::TestCase
ast.evaluate(scope)
end
- assert_equal("template #{value}\n", scope.lookupvar("output"),
- "%s did not get evaluated correctly" % string.inspect)
+
+ assert_equal(
+ "template #{value}\n", scope.lookupvar("output"),
+
+ "%s did not get evaluated correctly" % string.inspect)
end
end
@@ -378,8 +420,7 @@ class TestLangFunctions < Test::Unit::TestCase
}
assert(obj, "Did not autoload function")
- assert(Puppet::Parser::Functions.environment_module.method_defined?(:function_autofunc),
- "Did not set function correctly")
+ assert(Puppet::Parser::Functions.environment_module.method_defined?(:function_autofunc), "Did not set function correctly")
end
def test_search
diff --git a/test/language/parser.rb b/test/language/parser.rb
index 18688aa40..b26982d16 100755
--- a/test/language/parser.rb
+++ b/test/language/parser.rb
@@ -80,8 +80,7 @@ class TestParser < Test::Unit::TestCase
@@tmpfiles << name
File.open(file, "w") { |f|
- f.puts "file { \"%s\": ensure => file, mode => 755 }\n" %
- name
+ f.puts "file { \"%s\": ensure => file, mode => 755 }\n" % name
}
end
@@ -673,8 +672,7 @@ file { "/tmp/yayness":
end
[one, two].each do |file|
- assert(@logs.detect { |l| l.message =~ /importing '#{file}'/},
- "did not import %s" % file)
+ assert(@logs.detect { |l| l.message =~ /importing '#{file}'/}, "did not import %s" % file)
end
end
@@ -743,7 +741,6 @@ file { "/tmp/yayness":
assert_nothing_raised do
result = parser.newdefine "FunTest"
end
- assert_equal(result, parser.find_definition("", "fUntEst"),
- "%s was not matched" % "fUntEst")
+ assert_equal(result, parser.find_definition("", "fUntEst"), "%s was not matched" % "fUntEst")
end
end
diff --git a/test/language/scope.rb b/test/language/scope.rb
index 0bed35c14..16149a6be 100755
--- a/test/language/scope.rb
+++ b/test/language/scope.rb
@@ -63,29 +63,40 @@ class TestScope < Test::Unit::TestCase
# Test that the scopes convert to hash structures correctly.
# For topscope recursive vs non-recursive should be identical
assert_equal(topscope.to_hash(false), topscope.to_hash(true),
- "Recursive and non-recursive hash is identical for topscope")
+ "Recursive and non-recursive hash is identical for topscope")
# Check the variable we expect is present.
- assert_equal({"first" => "topval"}, topscope.to_hash(),
- "topscope returns the expected hash of variables")
+ assert_equal({"first" => "topval"}, topscope.to_hash(), "topscope returns the expected hash of variables")
# Now, check that midscope does the right thing in all cases.
- assert_equal({"second" => "midval"},
- midscope.to_hash(false),
- "midscope non-recursive hash contains only midscope variable")
- assert_equal({"first" => "topval", "second" => "midval"},
- midscope.to_hash(true),
- "midscope recursive hash contains topscope variable also")
+
+ assert_equal(
+ {"second" => "midval"},
+ midscope.to_hash(false),
+
+ "midscope non-recursive hash contains only midscope variable")
+
+ assert_equal(
+ {"first" => "topval", "second" => "midval"},
+ midscope.to_hash(true),
+
+ "midscope recursive hash contains topscope variable also")
# Finally, check the ability to shadow symbols by adding a shadow to
# bottomscope, then checking that we see the right stuff.
botscope.setvar("first", "shadowval")
- assert_equal({"third" => "botval", "first" => "shadowval"},
- botscope.to_hash(false),
- "botscope has the right non-recursive hash")
- assert_equal({"third" => "botval", "first" => "shadowval", "second" => "midval"},
- botscope.to_hash(true),
- "botscope values shadow parent scope values")
+
+ assert_equal(
+ {"third" => "botval", "first" => "shadowval"},
+ botscope.to_hash(false),
+
+ "botscope has the right non-recursive hash")
+
+ assert_equal(
+ {"third" => "botval", "first" => "shadowval", "second" => "midval"},
+ botscope.to_hash(true),
+
+ "botscope values shadow parent scope values")
end
def test_declarative
@@ -120,15 +131,30 @@ class TestScope < Test::Unit::TestCase
# Make sure we know what we consider to be truth.
def test_truth
- assert_equal(true, Puppet::Parser::Scope.true?("a string"),
+
+ assert_equal(
+ true, Puppet::Parser::Scope.true?("a string"),
+
"Strings not considered true")
- assert_equal(true, Puppet::Parser::Scope.true?(true),
+
+ assert_equal(
+ true, Puppet::Parser::Scope.true?(true),
+
"True considered true")
- assert_equal(false, Puppet::Parser::Scope.true?(""),
+
+ assert_equal(
+ false, Puppet::Parser::Scope.true?(""),
+
"Empty strings considered true")
- assert_equal(false, Puppet::Parser::Scope.true?(false),
+
+ assert_equal(
+ false, Puppet::Parser::Scope.true?(false),
+
"false considered true")
- assert_equal(false, Puppet::Parser::Scope.true?(:undef),
+
+ assert_equal(
+ false, Puppet::Parser::Scope.true?(:undef),
+
"undef considered true")
end
@@ -195,15 +221,15 @@ include yay
@@host { puppet: ip => \"192.168.0.3\" }
Host <<||>>"
- config = nil
- # We run it twice because we want to make sure there's no conflict
- # if we pull it up from the database.
- node = mknode
- node.merge "hostname" => node.name
- 2.times { |i|
- catalog = Puppet::Parser::Compiler.new(node).compile
- assert_instance_of(Puppet::Parser::Resource, catalog.resource(:host, "puppet"))
- assert_instance_of(Puppet::Parser::Resource, catalog.resource(:host, "myhost"))
+ config = nil
+ # We run it twice because we want to make sure there's no conflict
+ # if we pull it up from the database.
+ node = mknode
+ node.merge "hostname" => node.name
+ 2.times { |i|
+ catalog = Puppet::Parser::Compiler.new(node).compile
+ assert_instance_of(Puppet::Parser::Resource, catalog.resource(:host, "puppet"))
+ assert_instance_of(Puppet::Parser::Resource, catalog.resource(:host, "myhost"))
}
ensure
Puppet[:storeconfigs] = false
@@ -218,14 +244,15 @@ Host <<||>>"
def test_namespaces
scope = mkscope
- assert_equal([""], scope.namespaces,
+
+ assert_equal(
+ [""], scope.namespaces,
+
"Started out with incorrect namespaces")
assert_nothing_raised { scope.add_namespace("fun::test") }
- assert_equal(["fun::test"], scope.namespaces,
- "Did not add namespace correctly")
+ assert_equal(["fun::test"], scope.namespaces, "Did not add namespace correctly")
assert_nothing_raised { scope.add_namespace("yay::test") }
- assert_equal(["fun::test", "yay::test"], scope.namespaces,
- "Did not add extra namespace correctly")
+ assert_equal(["fun::test", "yay::test"], scope.namespaces, "Did not add extra namespace correctly")
end
# #629 - undef should be "" or :undef
@@ -234,10 +261,16 @@ Host <<||>>"
scope.setvar("testing", :undef)
- assert_equal(:undef, scope.lookupvar("testing", false),
+
+ assert_equal(
+ :undef, scope.lookupvar("testing", false),
+
"undef was not returned as :undef when not string")
- assert_equal("", scope.lookupvar("testing", true),
+
+ assert_equal(
+ "", scope.lookupvar("testing", true),
+
"undef was not returned as '' when string")
end
end
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 0d647f7de..14a267d99 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -412,7 +412,10 @@ class TestSnippets < Test::Unit::TestCase
def snippet_componentrequire
%w{1 2}.each do |num|
- assert_file("/tmp/testing_component_requires#{num}",
+
+ assert_file(
+ "/tmp/testing_component_requires#{num}",
+
"#{num} does not exist")
end
end
@@ -433,29 +436,22 @@ class TestSnippets < Test::Unit::TestCase
end
def snippet_fqdefinition
- assert_file("/tmp/fqdefinition",
- "Did not make file from fully-qualified definition")
+ assert_file("/tmp/fqdefinition", "Did not make file from fully-qualified definition")
end
def snippet_subclass_name_duplication
- assert_file("/tmp/subclass_name_duplication1",
- "Did not make first file from duplicate subclass names")
- assert_file("/tmp/subclass_name_duplication2",
- "Did not make second file from duplicate subclass names")
+ assert_file("/tmp/subclass_name_duplication1", "Did not make first file from duplicate subclass names")
+ assert_file("/tmp/subclass_name_duplication2", "Did not make second file from duplicate subclass names")
end
def snippet_funccomma
- assert_file("/tmp/funccomma1",
- "Did not make first file from trailing function comma")
- assert_file("/tmp/funccomma2",
- "Did not make second file from trailing function comma")
+ assert_file("/tmp/funccomma1", "Did not make first file from trailing function comma")
+ assert_file("/tmp/funccomma2", "Did not make second file from trailing function comma")
end
def snippet_arraytrailingcomma
- assert_file("/tmp/arraytrailingcomma1",
- "Did not make first file from array")
- assert_file("/tmp/arraytrailingcomma2",
- "Did not make second file from array")
+ assert_file("/tmp/arraytrailingcomma1", "Did not make first file from array")
+ assert_file("/tmp/arraytrailingcomma2", "Did not make second file from array")
end
def snippet_multipleclass
diff --git a/test/language/transportable.rb b/test/language/transportable.rb
index 7ea6a176d..247a6eda3 100755
--- a/test/language/transportable.rb
+++ b/test/language/transportable.rb
@@ -78,8 +78,11 @@ class TestTransportable < Test::Unit::TestCase
assert(objects.include?(obj), "Missing obj %s[%s]" % [obj.type, obj.name])
end
- assert_equal(found.length,
+
+ assert_equal(
+ found.length,
top.flatten.find_all { |o| o.file == :funtest }.length,
+
"Found incorrect number of objects")
end
end
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index f94fb4cec..e11de04e2 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -52,11 +52,14 @@ module PuppetTest
def self.munge_argv
require 'getoptlong'
- result = GetoptLong.new(
- [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
- [ "--resolve", "-r", GetoptLong::REQUIRED_ARGUMENT ],
- [ "-n", GetoptLong::REQUIRED_ARGUMENT ],
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+
+ result = GetoptLong.new(
+
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--resolve", "-r", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "-n", GetoptLong::REQUIRED_ARGUMENT ],
+
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
)
usage = "USAGE: TESTOPTS='[-n <method> -n <method> ...] [-d]' rake [target] [target] ..."
@@ -93,7 +96,7 @@ module PuppetTest
# Find the root of the Puppet tree; this is not the test directory, but
# the parent of that dir.
def basedir(*list)
- unless defined? @@basedir
+ unless defined?(@@basedir)
Dir.chdir(File.dirname(__FILE__)) do
@@basedir = File.dirname(File.dirname(Dir.getwd))
end
@@ -110,7 +113,7 @@ module PuppetTest
end
def exampledir(*args)
- unless defined? @@exampledir
+ unless defined?(@@exampledir)
@@exampledir = File.join(basedir, "examples")
end
@@ -170,13 +173,16 @@ module PuppetTest
ENV["PATH"] += File::PATH_SEPARATOR + "/usr/sbin"
end
@memoryatstart = Puppet::Util.memory
- if defined? @@testcount
+ if defined?(@@testcount)
@@testcount += 1
else
@@testcount = 0
end
- @configpath = File.join(tmpdir,
+
+ @configpath = File.join(
+ tmpdir,
+
"configdir" + @@testcount.to_s + "/"
)
@@ -232,7 +238,7 @@ module PuppetTest
end
def tempfile
- if defined? @@tmpfilenum
+ if defined?(@@tmpfilenum)
@@tmpfilenum += 1
else
@@tmpfilenum = 1
@@ -259,13 +265,13 @@ module PuppetTest
end
def tmpdir
- unless defined? @tmpdir and @tmpdir
+ unless defined?(@tmpdir) and @tmpdir
@tmpdir = case Facter["operatingsystem"].value
- when "Darwin"; "/private/tmp"
- when "SunOS"; "/var/tmp"
- else
- "/tmp"
- end
+ when "Darwin"; "/private/tmp"
+ when "SunOS"; "/var/tmp"
+ else
+ "/tmp"
+ end
@tmpdir = File.join(@tmpdir, "puppettesting" + Process.pid.to_s)
@@ -314,8 +320,7 @@ module PuppetTest
diff = @memoryatend - @memoryatstart
if diff > 1000
- Puppet.info "%s#%s memory growth (%s to %s): %s" %
- [self.class, @method_name, @memoryatstart, @memoryatend, diff]
+ Puppet.info "%s#%s memory growth (%s to %s): %s" % [self.class, @method_name, @memoryatstart, @memoryatend, diff]
end
# reset all of the logs
diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb
index 30387f606..d421b292f 100644
--- a/test/lib/puppettest/fakes.rb
+++ b/test/lib/puppettest/fakes.rb
@@ -36,8 +36,7 @@ module PuppetTest
def []=(param, value)
param = symbolize(param)
unless @realresource.valid_parameter?(param)
- raise Puppet::DevError, "Invalid attribute %s for %s" %
- [param, @realresource.name]
+ raise Puppet::DevError, "Invalid attribute %s for %s" % [param, @realresource.name]
end
if @realresource.attrtype(param) == :property
@should[param] = value
diff --git a/test/lib/puppettest/filetesting.rb b/test/lib/puppettest/filetesting.rb
index 1aa1cf703..605de6a73 100644
--- a/test/lib/puppettest/filetesting.rb
+++ b/test/lib/puppettest/filetesting.rb
@@ -88,9 +88,7 @@ module PuppetTest::FileTesting
tolist = file_list(todir).sort
fromlist.sort.zip(tolist.sort).each { |a,b|
- assert_equal(a, b,
- "Fromfile %s with length %s does not match tofile %s with length %s" %
- [a, fromlist.length, b, tolist.length])
+ assert_equal(a, b, "Fromfile %s with length %s does not match tofile %s with length %s" % [a, fromlist.length, b, tolist.length])
}
#assert_equal(fromlist,tolist)
@@ -103,18 +101,21 @@ module PuppetTest::FileTesting
fromstat = File.stat(fromfile)
tostat = File.stat(tofile)
[:ftype,:gid,:mode,:uid].each { |method|
+
assert_equal(
- fromstat.send(method),
- tostat.send(method)
- )
- next if fromstat.ftype == "directory"
- if checked < 10 and i % 3 == 0
- from = File.open(fromfile) { |f| f.read }
- to = File.open(tofile) { |f| f.read }
+ fromstat.send(method),
+
+ tostat.send(method)
+ )
+
+ next if fromstat.ftype == "directory"
+ if checked < 10 and i % 3 == 0
+ from = File.open(fromfile) { |f| f.read }
+ to = File.open(tofile) { |f| f.read }
- assert_equal(from,to)
- checked += 1
+ assert_equal(from,to)
+ checked += 1
end
}
}
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index 5ca5123e8..f4f0eeb44 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -12,7 +12,7 @@ module PuppetTest::ParserTesting
attr_writer :evaluate
def evaluated?
- defined? @evaluated and @evaluated
+ defined?(@evaluated) and @evaluated
end
def evaluate(*args)
@@ -101,11 +101,14 @@ module PuppetTest::ParserTesting
title = stringobj(title)
end
assert_nothing_raised("Could not create %s %s" % [type, title]) {
+
return AST::Resource.new(
+
:file => __FILE__,
:line => __LINE__,
:title => title,
:type => type,
+
:parameters => resourceinst(params)
)
}
@@ -119,10 +122,13 @@ module PuppetTest::ParserTesting
def resourceoverride(type, title, params)
assert_nothing_raised("Could not create %s %s" % [type, name]) {
+
return AST::ResourceOverride.new(
+
:file => __FILE__,
:line => __LINE__,
:object => resourceref(type, title),
+
:type => type,
:parameters => resourceinst(params)
)
@@ -131,10 +137,13 @@ module PuppetTest::ParserTesting
def resourceref(type, title)
assert_nothing_raised("Could not create %s %s" % [type, title]) {
+
return AST::ResourceReference.new(
+
:file => __FILE__,
:line => __LINE__,
:type => type,
+
:title => stringobj(title)
)
}
@@ -148,34 +157,46 @@ module PuppetTest::ParserTesting
def nameobj(name)
assert_nothing_raised("Could not create name %s" % name) {
+
return AST::Name.new(
- :file => tempfile(),
- :line => rand(100),
- :value => name
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :value => name
+ )
}
end
def typeobj(name)
assert_nothing_raised("Could not create type %s" % name) {
+
return AST::Type.new(
- :file => tempfile(),
- :line => rand(100),
- :value => name
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :value => name
+ )
}
end
def nodedef(name)
assert_nothing_raised("Could not create node %s" % name) {
+
return AST::NodeDef.new(
+
:file => tempfile(),
+
:line => rand(100),
:names => nameobj(name),
- :code => AST::ASTArray.new(
- :children => [
- varobj("%svar" % name, "%svalue" % name),
- fileobj("/%s" % name)
+
+ :code => AST::ASTArray.new(
+
+ :children => [
+ varobj("%svar" % name, "%svalue" % name),
+
+ fileobj("/%s" % name)
]
)
)
@@ -187,11 +208,14 @@ module PuppetTest::ParserTesting
params = hash.collect { |param, value|
resourceparam(param, value)
}
- return AST::ResourceInstance.new(
- :file => tempfile(),
- :line => rand(100),
- :children => params
- )
+
+ return AST::ResourceInstance.new(
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :children => params
+ )
}
end
@@ -201,21 +225,27 @@ module PuppetTest::ParserTesting
value = stringobj(value)
end
assert_nothing_raised("Could not create param %s" % param) {
+
return AST::ResourceParam.new(
- :file => tempfile(),
- :line => rand(100),
- :param => param,
- :value => value
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :param => param,
+ :value => value
+ )
}
end
def stringobj(value)
+
AST::String.new(
- :file => tempfile(),
- :line => rand(100),
- :value => value
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :value => value
+ )
end
def varobj(name, value)
@@ -223,54 +253,69 @@ module PuppetTest::ParserTesting
value = stringobj(value)
end
assert_nothing_raised("Could not create %s code" % name) {
+
return AST::VarDef.new(
- :file => tempfile(),
- :line => rand(100),
- :name => nameobj(name),
- :value => value
- )
+
+ :file => tempfile(),
+
+ :line => rand(100),
+ :name => nameobj(name),
+ :value => value
+ )
}
end
def varref(name)
assert_nothing_raised("Could not create %s variable" % name) {
+
return AST::Variable.new(
- :file => __FILE__,
- :line => __LINE__,
- :value => name
- )
+
+ :file => __FILE__,
+ :line => __LINE__,
+
+ :value => name
+ )
}
end
def argobj(name, value)
assert_nothing_raised("Could not create %s compargument" % name) {
return AST::CompArgument.new(
- :children => [nameobj(name), stringobj(value)]
- )
+ :children => [nameobj(name), stringobj(value)]
+ )
}
end
def defaultobj(type, params)
pary = []
params.each { |p,v|
+
pary << AST::ResourceParam.new(
- :file => __FILE__,
- :line => __LINE__,
- :param => p,
- :value => stringobj(v)
- )
+
+ :file => __FILE__,
+ :line => __LINE__,
+ :param => p,
+
+ :value => stringobj(v)
+ )
}
- past = AST::ASTArray.new(
- :file => __FILE__,
- :line => __LINE__,
- :children => pary
- )
+
+ past = AST::ASTArray.new(
+
+ :file => __FILE__,
+ :line => __LINE__,
+
+ :children => pary
+ )
assert_nothing_raised("Could not create defaults for %s" % type) {
+
return AST::ResourceDefaults.new(
+
:file => __FILE__,
:line => __LINE__,
:type => type,
+
:parameters => past
)
}
@@ -283,9 +328,12 @@ module PuppetTest::ParserTesting
def functionobj(function, name, ftype = :statement)
func = nil
assert_nothing_raised do
+
func = Puppet::Parser::AST::Function.new(
+
:name => function,
:ftype => ftype,
+
:arguments => AST::ASTArray.new(
:children => [nameobj(name)]
)
diff --git a/test/lib/puppettest/railstesting.rb b/test/lib/puppettest/railstesting.rb
index 04ed0bf09..3af593762 100644
--- a/test/lib/puppettest/railstesting.rb
+++ b/test/lib/puppettest/railstesting.rb
@@ -32,8 +32,11 @@ module PuppetTest::RailsTesting
# Now build a resource
resources = []
- resources << mkresource(:type => type, :title => title, :exported => true,
- :parameters => params)
+
+ resources << mkresource(
+ :type => type, :title => title, :exported => true,
+
+ :parameters => params)
# Now collect our facts
facts = Facter.to_hash
diff --git a/test/lib/puppettest/resourcetesting.rb b/test/lib/puppettest/resourcetesting.rb
index 2e4db1d76..0949dfff4 100644
--- a/test/lib/puppettest/resourcetesting.rb
+++ b/test/lib/puppettest/resourcetesting.rb
@@ -4,9 +4,15 @@ module PuppetTest::ResourceTesting
def mkevaltest(parser = nil)
parser ||= mkparser
- @parser.newdefine("evaltest",
+
+ @parser.newdefine(
+ "evaltest",
+
:arguments => [%w{one}, ["two", stringobj("755")]],
- :code => resourcedef("file", "/tmp",
+
+ :code => resourcedef(
+ "file", "/tmp",
+
"owner" => varref("one"), "mode" => varref("two"))
)
end
diff --git a/test/lib/puppettest/servertest.rb b/test/lib/puppettest/servertest.rb
index d658ddba7..bda99c66a 100644
--- a/test/lib/puppettest/servertest.rb
+++ b/test/lib/puppettest/servertest.rb
@@ -6,7 +6,7 @@ module PuppetTest::ServerTest
def setup
super
- if defined? @@port
+ if defined?(@@port)
@@port += 1
else
@@port = 20000
@@ -47,8 +47,11 @@ module PuppetTest::ServerTest
# then create the actual server
server = nil
assert_nothing_raised {
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => handlers
)
}
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb
index 4d9dd2129..db850d699 100644
--- a/test/lib/puppettest/support/utils.rb
+++ b/test/lib/puppettest/support/utils.rb
@@ -55,7 +55,7 @@ module PuppetTest::Support::Utils
else
puts id
end
- unless defined? @me
+ unless defined?(@me)
raise "Could not retrieve user name; 'id' did not work"
end
end
diff --git a/test/network/authconfig.rb b/test/network/authconfig.rb
index b619bec7e..6437aefea 100755
--- a/test/network/authconfig.rb
+++ b/test/network/authconfig.rb
@@ -43,16 +43,11 @@ class TestAuthConfig < Test::Unit::TestCase
}
assert_nothing_raised {
- assert(config.allowed?(request("pelementserver.describe",
- "culain.madstop.com", "1.1.1.1")), "Did not allow host")
- assert(! config.allowed?(request("pelementserver.describe",
- "culain.madstop.com", "10.10.1.1")), "Allowed host")
- assert(config.allowed?(request("fileserver.yay",
- "culain.madstop.com", "10.1.1.1")), "Did not allow host to fs")
- assert(! config.allowed?(request("fileserver.yay",
- "culain.madstop.com", "10.10.1.1")), "Allowed host to fs")
- assert(config.allowed?(request("fileserver.list",
- "culain.madstop.com", "10.10.1.1")), "Did not allow host to fs.list")
+ assert(config.allowed?(request("pelementserver.describe", "culain.madstop.com", "1.1.1.1")), "Did not allow host")
+ assert(! config.allowed?(request("pelementserver.describe", "culain.madstop.com", "10.10.1.1")), "Allowed host")
+ assert(config.allowed?(request("fileserver.yay", "culain.madstop.com", "10.1.1.1")), "Did not allow host to fs")
+ assert(! config.allowed?(request("fileserver.yay", "culain.madstop.com", "10.10.1.1")), "Allowed host to fs")
+ assert(config.allowed?(request("fileserver.list", "culain.madstop.com", "10.10.1.1")), "Did not allow host to fs.list")
}
end
@@ -63,7 +58,10 @@ class TestAuthConfig < Test::Unit::TestCase
other = nil
assert_nothing_raised { other = Puppet::Network::AuthConfig.main }
- assert_equal(auth.object_id, other.object_id,
+
+ assert_equal(
+ auth.object_id, other.object_id,
+
"did not get same authconfig from class")
end
end
diff --git a/test/network/authorization.rb b/test/network/authorization.rb
index 3c1f71e49..680d5676d 100755
--- a/test/network/authorization.rb
+++ b/test/network/authorization.rb
@@ -61,8 +61,7 @@ class TestAuthConfig < Test::Unit::TestCase
auth = nil
assert_nothing_raised { auth = obj.send(:authconfig) }
assert(auth, "did not get auth")
- assert_equal(Puppet::Network::AuthConfig.main.object_id, auth.object_id,
- "did not get main authconfig")
+ assert_equal(Puppet::Network::AuthConfig.main.object_id, auth.object_id, "did not get main authconfig")
end
def test_authorize
@@ -84,7 +83,10 @@ class TestAuthConfig < Test::Unit::TestCase
# Now set our run_mode to master, so calls are allowed
Puppet.run_mode.stubs(:master?).returns true
- assert(@obj.authorized?(@request),
+
+ assert(
+ @obj.authorized?(@request),
+
"Denied call with no config file and master")
assert_logged(:debug, /Allowing/, "did not log call")
diff --git a/test/network/authstore.rb b/test/network/authstore.rb
index 93f379164..c225b246b 100755
--- a/test/network/authstore.rb
+++ b/test/network/authstore.rb
@@ -93,9 +93,15 @@ class TestAuthStore < Test::Unit::TestCase
@store.deny("*.sub.madstop.com")
}
- assert(@store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
+ assert(
+ @store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
"hostname not allowed")
- assert(! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),
+
+ assert(
+ ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),
+
"subname name allowed")
end
@@ -105,9 +111,15 @@ class TestAuthStore < Test::Unit::TestCase
@store.deny("192.168.0.0/24")
}
- assert(@store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
+ assert(
+ @store.allowed?("hostname.madstop.com", "192.168.1.50"),
+
"hostname not allowed")
- assert(! @store.allowed?("hostname.madstop.com", "192.168.0.50"),
+
+ assert(
+ ! @store.allowed?("hostname.madstop.com", "192.168.0.50"),
+
"Host allowed over IP")
end
@@ -128,22 +140,31 @@ class TestAuthStore < Test::Unit::TestCase
def test_store
assert_nothing_raised do
- assert_nil(@store.send(:store, :allow, "*.host.com"),
+
+ assert_nil(
+ @store.send(:store, :allow, "*.host.com"),
+
"store did not return nil")
end
assert_equal([Declaration.new(:allow, "*.host.com")],
- @store.send(:instance_variable_get, "@declarations"),
+ @store.send(:instance_variable_get, "@declarations"),
"Did not store declaration")
# Now add another one and make sure it gets sorted appropriately
assert_nothing_raised do
- assert_nil(@store.send(:store, :allow, "me.host.com"),
+
+ assert_nil(
+ @store.send(:store, :allow, "me.host.com"),
+
"store did not return nil")
end
- assert_equal([
- Declaration.new(:allow, "me.host.com"),
- Declaration.new(:allow, "*.host.com")
+
+ assert_equal(
+ [
+ Declaration.new(:allow, "me.host.com"),
+
+ Declaration.new(:allow, "*.host.com")
],
@store.send(:instance_variable_get, "@declarations"),
"Did not sort declarations")
@@ -160,11 +181,17 @@ class TestAuthStore < Test::Unit::TestCase
store = Puppet::Network::AuthStore.new
assert_nothing_raised do
- assert_nil(store.allow("*"),
+
+ assert_nil(
+ store.allow("*"),
+
"allow did not return nil")
end
- assert(store.globalallow?,
+
+ assert(
+ store.globalallow?,
+
"did not enable global allow")
end
@@ -186,7 +213,10 @@ class TestAuthStore < Test::Unit::TestCase
inval$id
}.each { |pat|
- assert_raise(Puppet::AuthStoreError,
+
+ assert_raise(
+ Puppet::AuthStoreError,
+
"name '%s' was allowed" % pat) {
@store.allow(pat)
}
@@ -216,7 +246,10 @@ class TestAuthStore < Test::Unit::TestCase
@store.allow("domain.*.com")
}
- assert(!@store.allowed?("very.long.domain.name.com", "1.2.3.4"),
+
+ assert(
+ !@store.allowed?("very.long.domain.name.com", "1.2.3.4"),
+
"Long hostname allowed")
assert_raise(Puppet::AuthStoreError) {
@@ -229,14 +262,16 @@ class TestAuthStore < Test::Unit::TestCase
@store.allow("hostname.com")
%w{hostname.com Hostname.COM hostname.Com HOSTNAME.COM}.each do |name|
- assert(@store.allowed?(name, "127.0.0.1"),
- "did not allow %s" % name)
+ assert(@store.allowed?(name, "127.0.0.1"), "did not allow %s" % name)
end
end
def test_allowed?
Puppet[:trace] = false
- assert(@store.allowed?(nil, nil),
+
+ assert(
+ @store.allowed?(nil, nil),
+
"Did not default to true for local checks")
assert_raise(Puppet::DevError, "did not fail on one input") do
@store.allowed?("host.com", nil)
@@ -252,13 +287,19 @@ class TestAuthStore < Test::Unit::TestCase
@store.allow("host.madstop.com")
@store.deny("*.madstop.com")
- assert(@store.allowed?("host.madstop.com", "192.168.0.1"),
+
+ assert(
+ @store.allowed?("host.madstop.com", "192.168.0.1"),
+
"More specific allowal by name failed")
@store.allow("192.168.0.1")
@store.deny("192.168.0.0/24")
- assert(@store.allowed?("host.madstop.com", "192.168.0.1"),
+
+ assert(
+ @store.allowed?("host.madstop.com", "192.168.0.1"),
+
"More specific allowal by ip failed")
end
@@ -344,8 +385,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
end
[:name, :pattern, :length].zip(output).each do |method, value|
- assert_equal(value, @decl.send(method),
- "Got incorrect value for %s from %s" % [method, input])
+ assert_equal(value, @decl.send(method), "Got incorrect value for %s from %s" % [method, input])
end
end
@@ -365,14 +405,16 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
def test_result
["allow", :allow].each do |val|
assert_nothing_raised { @decl.type = val }
- assert_equal(true, @decl.result, "did not result to true with %s" %
- val.inspect)
+ assert_equal(true, @decl.result, "did not result to true with %s" % val.inspect)
end
[:deny, "deny"].each do |val|
assert_nothing_raised { @decl.type = val }
- assert_equal(false, @decl.result,
- "did not result to false with %s" % val.inspect)
+
+ assert_equal(
+ false, @decl.result,
+
+ "did not result to false with %s" % val.inspect)
end
["yay", 1, nil, false, true].each do |val|
@@ -391,8 +433,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
"*.HOSTNAME.Com" => %w{com hostname *},
}.each do |input, output|
- assert_equal(output, @decl.send(:munge_name, input),
- "munged %s incorrectly" % input)
+ assert_equal(output, @decl.send(:munge_name, input), "munged %s incorrectly" % input)
end
end
@@ -414,10 +455,16 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
ip_exact = Declaration.new(:allow, "192.168.0.1")
ip_range = Declaration.new(:allow, "192.168.0.*")
- assert_equal(-1, host_exact <=> host_range,
+
+ assert_equal(
+ -1, host_exact <=> host_range,
+
"exact name match did not sort first")
- assert_equal(-1, ip_exact <=> ip_range,
+
+ assert_equal(
+ -1, ip_exact <=> ip_range,
+
"exact ip match did not sort first")
# Next make sure we sort by length
@@ -431,10 +478,12 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
assert_equal(-1, ip24 <=> ip16, "/16 sorted before /24 in ip with masks")
# Make sure ip checks sort before host checks
- assert_equal(-1, ip_exact <=> host_exact,
- "IP exact did not sort before host exact")
+ assert_equal(-1, ip_exact <=> host_exact, "IP exact did not sort before host exact")
+
+
+ assert_equal(
+ -1, ip_range <=> host_range,
- assert_equal(-1, ip_range <=> host_range,
"IP range did not sort before host range")
host_long = Declaration.new(:allow, "*.domain.host.com")
@@ -447,20 +496,21 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
assert_equal(-1, host_deny <=> host_exact, "deny did not sort before allow when exact")
host_range_deny = Declaration.new(:deny, "*.host.com")
- assert_equal(-1, host_range_deny <=> host_range,
- "deny did not sort before allow when ranged")
+ assert_equal(-1, host_range_deny <=> host_range, "deny did not sort before allow when ranged")
ip_allow = Declaration.new(:allow, "192.168.0.0/16")
ip_deny = Declaration.new(:deny, "192.168.0.0/16")
- assert_equal(-1, ip_deny <=> ip_allow,
+
+ assert_equal(
+ -1, ip_deny <=> ip_allow,
+
"deny did not sort before allow in ip range")
%w{host.com *.domain.com 192.168.0.1 192.168.0.1/24}.each do |decl|
assert_equal(0, Declaration.new(:allow, decl) <=>
Declaration.new(:allow, decl),
- "Equivalent declarations for %s were considered different" %
- decl
+ "Equivalent declarations for %s were considered different" % decl
)
end
end
@@ -481,10 +531,8 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase
assert(! host.send(:matchname?, "yay.com"), "incorrect match")
domain = Declaration.new(:allow, "*.domain.com")
- %w{host.domain.com domain.com very.long.domain.com very-long.domain.com
- }.each do |name|
- assert(domain.send(:matchname?, name),
- "Did not match %s" % name)
+ %w{host.domain.com domain.com very.long.domain.com very-long.domain.com }.each do |name|
+ assert(domain.send(:matchname?, name), "Did not match %s" % name)
end
end
end
diff --git a/test/network/client/ca.rb b/test/network/client/ca.rb
index 1741c850a..ae81547db 100755
--- a/test/network/client/ca.rb
+++ b/test/network/client/ca.rb
@@ -23,8 +23,7 @@ class TestClientCA < Test::Unit::TestCase
end
[:hostprivkey, :hostcert, :localcacert].each do |name|
- assert(FileTest.exists?(Puppet.settings[name]),
- "Did not create cert %s" % name)
+ assert(FileTest.exists?(Puppet.settings[name]), "Did not create cert %s" % name)
end
end
@@ -64,8 +63,7 @@ class TestClientCA < Test::Unit::TestCase
end
# And then make sure the cert isn't written to disk
- assert(! FileTest.exists?(Puppet[:hostcert]),
- "Invalid cert got written to disk")
+ assert(! FileTest.exists?(Puppet[:hostcert]), "Invalid cert got written to disk")
end
end
diff --git a/test/network/handler/ca.rb b/test/network/handler/ca.rb
index 503d0188d..4d1531228 100755
--- a/test/network/handler/ca.rb
+++ b/test/network/handler/ca.rb
@@ -191,8 +191,11 @@ class TestCA < Test::Unit::TestCase
server = nil
Puppet.stubs(:master?).returns true
assert_nothing_raised {
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
diff --git a/test/network/handler/fileserver.rb b/test/network/handler/fileserver.rb
index f17d82bf6..357192716 100755
--- a/test/network/handler/fileserver.rb
+++ b/test/network/handler/fileserver.rb
@@ -72,8 +72,11 @@ class TestFileServer < Test::Unit::TestCase
def test_namefailures
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -95,8 +98,11 @@ class TestFileServer < Test::Unit::TestCase
# and make our fileserver
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -129,8 +135,11 @@ class TestFileServer < Test::Unit::TestCase
file = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -183,8 +192,11 @@ class TestFileServer < Test::Unit::TestCase
checks = Puppet::Network::Handler.fileserver::CHECKPARAMS
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -221,8 +233,11 @@ class TestFileServer < Test::Unit::TestCase
def test_mountroot
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -250,8 +265,11 @@ class TestFileServer < Test::Unit::TestCase
def test_recursionlevels
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -301,8 +319,11 @@ class TestFileServer < Test::Unit::TestCase
def test_listedpath
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -344,8 +365,11 @@ class TestFileServer < Test::Unit::TestCase
def test_widelists
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -384,8 +408,11 @@ class TestFileServer < Test::Unit::TestCase
checks = Puppet::Network::Handler.fileserver::CHECKPARAMS
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -425,7 +452,10 @@ class TestFileServer < Test::Unit::TestCase
# Now try to describe some sources that don't even exist
retval = nil
- assert_raise(Puppet::Network::Handler::FileServerError,
+
+ assert_raise(
+ Puppet::Network::Handler::FileServerError,
+
"Describing non-existent mount did not raise an error") {
retval = server.describe("/notmounted/" + "noexisties")
}
@@ -480,14 +510,17 @@ class TestFileServer < Test::Unit::TestCase
path #{basedir}/those
"
- }
+ }
- # create a server with the file
- assert_nothing_raised {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => false,
- :Config => conffile
+ # create a server with the file
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => false,
+
+ :Config => conffile
)
}
@@ -545,15 +578,16 @@ class TestFileServer < Test::Unit::TestCase
case type
when :deny
- assert_raise(Puppet::AuthorizationError,
- "Host %s, ip %s, allowed %s" %
- [host, ip, mount]) {
+
+ assert_raise(
+ Puppet::AuthorizationError,
+
+ "Host %s, ip %s, allowed %s" % [host, ip, mount]) {
list = server.list(mount, :manage, true, false, host, ip)
}
when :allow
- assert_nothing_raised("Host %s, ip %s, denied %s" %
- [host, ip, mount]) {
- list = server.list(mount, :manage, true, false, host, ip)
+ assert_nothing_raised("Host %s, ip %s, denied %s" % [host, ip, mount]) {
+ list = server.list(mount, :manage, true, false, host, ip)
}
end
}
@@ -574,8 +608,8 @@ class TestFileServer < Test::Unit::TestCase
"
}
- invalidconfigs = [
-"[not valid]
+ invalidconfigs = [
+ "[not valid]
path /this/path/does/not/exist
allow 192.168.0.*
",
@@ -589,24 +623,30 @@ class TestFileServer < Test::Unit::TestCase
"
]
- invalidmounts.each { |mount, text|
- File.open(conffile, "w") { |f|
- f.print text
+ invalidmounts.each { |mount, text|
+ File.open(conffile, "w") { |f|
+ f.print text
}
# create a server with the file
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => conffile
)
}
- assert_raise(Puppet::Network::Handler::FileServerError,
- "Invalid mount was mounted") {
- server.list(mount, :manage)
+
+ assert_raise(
+ Puppet::Network::Handler::FileServerError,
+
+ "Invalid mount was mounted") {
+ server.list(mount, :manage)
}
}
@@ -618,11 +658,17 @@ class TestFileServer < Test::Unit::TestCase
# create a server with the file
server = nil
- assert_raise(Puppet::Network::Handler::FileServerError,
- "Invalid config %s did not raise error" % i) {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => true,
- :Config => conffile
+
+ assert_raise(
+ Puppet::Network::Handler::FileServerError,
+
+ "Invalid config %s did not raise error" % i) {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => true,
+
+ :Config => conffile
)
}
}
@@ -643,29 +689,34 @@ class TestFileServer < Test::Unit::TestCase
path #{dir}
allow test1.domain.com
"
- }
+ }
- # Reset the timeout, so we reload faster
- Puppet[:filetimeout] = 0.5
+ # Reset the timeout, so we reload faster
+ Puppet[:filetimeout] = 0.5
- # start our server with a fast timeout
- assert_nothing_raised {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => false,
- :Config => conffile
+ # start our server with a fast timeout
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => false,
+
+ :Config => conffile
)
}
list = nil
assert_nothing_raised {
- list = server.list("/thing/", :manage, false, false,
+
+ list = server.list(
+ "/thing/", :manage, false, false,
+
"test1.domain.com", "127.0.0.1")
}
assert(list != "", "List returned nothing in rereard test")
assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
- list = server.list("/thing/", :manage, false, false,
- "test2.domain.com", "127.0.0.1")
+ list = server.list("/thing/", :manage, false, false, "test2.domain.com", "127.0.0.1")
}
sleep 1
@@ -676,16 +727,14 @@ class TestFileServer < Test::Unit::TestCase
path #{dir}
allow test2.domain.com
"
- }
+ }
- assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
- list = server.list("/thing/", :manage, false, false,
- "test1.domain.com", "127.0.0.1")
+ assert_raise(Puppet::AuthorizationError, "List allowed invalid host") {
+ list = server.list("/thing/", :manage, false, false, "test1.domain.com", "127.0.0.1")
}
assert_nothing_raised {
- list = server.list("/thing/", :manage, false, false,
- "test2.domain.com", "127.0.0.1")
+ list = server.list("/thing/", :manage, false, false, "test2.domain.com", "127.0.0.1")
}
assert(list != "", "List returned nothing in rereard test")
@@ -716,8 +765,11 @@ class TestFileServer < Test::Unit::TestCase
File.open(file, "w") { |f| f.puts "yay" }
File.symlink(file, link)
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -773,8 +825,7 @@ class TestFileServer < Test::Unit::TestCase
client1_hostdir => "client1\n",
client2_fqdndir => client2 + "\n"
}
- [fsdir, hostdir, fqdndir,
- client1_hostdir, client2_fqdndir].each { |d| Dir.mkdir(d) }
+ [fsdir, hostdir, fqdndir, client1_hostdir, client2_fqdndir].each { |d| Dir.mkdir(d) }
[client1_hostdir, client2_fqdndir].each do |d|
File.open(File.join(d, "file.txt"), "w") do |f|
@@ -791,13 +842,16 @@ allow *
path #{fqdndir}/%H
allow *
")
- end
+ end
- server = nil
- assert_nothing_raised {
- server = Puppet::Network::Handler.fileserver.new(
- :Local => true,
- :Config => conffile
+ server = nil
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler.fileserver.new(
+
+ :Local => true,
+
+ :Config => conffile
)
}
@@ -938,34 +992,37 @@ allow *
# Do a round of checks with a fake client
client = "host.domain.com"
{"%h" => "host", # Short name
- "%H" => client, # Full name
- "%d" => "domain.com", # domain
- "%%" => "%", # escape
- "%o" => "%o" # other
- }.each do |pat, repl|
- result = check.call(client, pat, repl)
- end
+ "%H" => client, # Full name
+ "%d" => "domain.com", # domain
+ "%%" => "%", # escape
+ "%o" => "%o" # other
+ }.each do |pat, repl|
+ result = check.call(client, pat, repl)
+ end
# Now, check that they use Facter info
client = nil
Facter.stubs(:value).with { |v| v.to_s == "hostname" }.returns("myhost")
Facter.stubs(:value).with { |v| v.to_s == "domain" }.returns("mydomain.com")
- Facter.stubs(:to_hash).returns({
- :ipaddress => "127.0.0.1",
- :hostname => "myhost",
- :domain => "mydomain.com",
+
+ Facter.stubs(:to_hash).returns(
+ {
+ :ipaddress => "127.0.0.1",
+ :hostname => "myhost",
+ :domain => "mydomain.com",
+
})
{"%h" => "myhost", # Short name
- "%H" => "myhost.mydomain.com", # Full name
- "%d" => "mydomain.com", # domain
- "%%" => "%", # escape
- "%o" => "%o" # other
- }.each do |pat, repl|
- check.call(client, pat, repl)
- end
+ "%H" => "myhost.mydomain.com", # Full name
+ "%d" => "mydomain.com", # domain
+ "%%" => "%", # escape
+ "%o" => "%o" # other
+ }.each do |pat, repl|
+ check.call(client, pat, repl)
+ end
end
@@ -973,8 +1030,11 @@ allow *
def test_fileserver_expansion
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler.fileserver.new(
+
:Local => true,
+
:Config => false
)
}
@@ -986,11 +1046,14 @@ allow *
ip = '127.0.0.1'
- Facter.stubs(:to_hash).returns({
- :kernel => kernel_fact,
- :ipaddress => "127.0.0.1",
- :hostname => "myhost",
- :domain => "mydomain.com",
+
+ Facter.stubs(:to_hash).returns(
+ {
+ :kernel => kernel_fact,
+ :ipaddress => "127.0.0.1",
+ :hostname => "myhost",
+ :domain => "mydomain.com",
+
})
Dir.mkdir(dir)
@@ -1047,7 +1110,7 @@ allow *
File::open(file, "w") { |f| f.print name }
end
- Puppet::Module::find(name)
+ Puppet::Module::find(name)
end
conffile = tempfile
@@ -1057,8 +1120,11 @@ allow *
# create a server with the file
server = nil
assert_nothing_raised {
+
server = Puppet::Network::Handler::FileServer.new(
+
:Local => false ,
+
:Config => conffile
)
}
@@ -1080,8 +1146,7 @@ allow *
end
assert_nothing_raised("Host 'allow' denied #{mount}") {
- server.list(mount, :manage, true, false,
- 'allow.example.com', "192.168.0.1")
+ server.list(mount, :manage, true, false, 'allow.example.com', "192.168.0.1")
}
end
end
@@ -1109,14 +1174,17 @@ allow *
path #{basedir}/thing
allow 192.168.0.*
"
- }
+ }
- # create a server with the file
- server = nil
- assert_nothing_raised {
- server = Puppet::Network::Handler::FileServer.new(
- :Local => false,
- :Config => conffile
+ # create a server with the file
+ server = nil
+ assert_nothing_raised {
+
+ server = Puppet::Network::Handler::FileServer.new(
+
+ :Local => false,
+
+ :Config => conffile
)
}
@@ -1136,14 +1204,15 @@ allow *
assert_describe(mount, file, server)
# now let's check that things are being correctly forbidden
- assert_raise(Puppet::AuthorizationError,
- "Host 'deny' allowed #{mount}") {
- server.list(mount, :manage, true, false,
- 'deny.example.com', "192.168.1.1")
+
+ assert_raise(
+ Puppet::AuthorizationError,
+
+ "Host 'deny' allowed #{mount}") {
+ server.list(mount, :manage, true, false, 'deny.example.com', "192.168.1.1")
}
assert_nothing_raised("Host 'allow' denied #{mount}") {
- server.list(mount, :manage, true, false,
- 'allow.example.com', "192.168.0.1")
+ server.list(mount, :manage, true, false, 'allow.example.com', "192.168.0.1")
}
end
@@ -1161,8 +1230,11 @@ allow *
].each do |failer|
File.open(config, "w") { |f| f.puts failer }
assert_raise(Puppet::Network::Handler::FileServerError, "Did not fail on %s" % failer.inspect) {
+
server = Puppet::Network::Handler::FileServer.new(
+
:Local => false,
+
:Config => config
)
}
@@ -1172,8 +1244,8 @@ allow *
def test_can_start_without_configuration
Puppet[:fileserverconfig] = tempfile
assert_nothing_raised("Could not create fileserver when configuration is absent") do
- server = Puppet::Network::Handler::FileServer.new(
- :Local => false
+ server = Puppet::Network::Handler::FileServer.new(
+ :Local => false
)
end
end
diff --git a/test/network/rights.rb b/test/network/rights.rb
index 71b8c3765..80d6ceafe 100755
--- a/test/network/rights.rb
+++ b/test/network/rights.rb
@@ -23,7 +23,10 @@ class TestRights < Test::Unit::TestCase
@store.newright(:write)
}
- assert(! @store.allowed?(:write, "host.madstop.com", "0.0.0.0"),
+
+ assert(
+ ! @store.allowed?(:write, "host.madstop.com", "0.0.0.0"),
+
"Defaulted to allowing access")
assert_nothing_raised {
diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb
index e2493b424..7fd362b39 100755
--- a/test/network/server/webrick.rb
+++ b/test/network/server/webrick.rb
@@ -24,8 +24,11 @@ class TestWebrickServer < Test::Unit::TestCase
def test_basics
server = nil
assert_raise(Puppet::Error, "server succeeded with no cert") do
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:Status => nil
}
@@ -33,8 +36,11 @@ class TestWebrickServer < Test::Unit::TestCase
end
assert_nothing_raised("Could not create simple server") do
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
@@ -70,8 +76,11 @@ class TestWebrickServer < Test::Unit::TestCase
client = nil
assert_nothing_raised() {
- client = Puppet::Network::Client.status.new(
+
+ client = Puppet::Network::Client.status.new(
+
:Server => "localhost",
+
:Port => @@port
)
}
@@ -82,8 +91,11 @@ class TestWebrickServer < Test::Unit::TestCase
server = nil
Puppet[:certdnsnames] = "localhost"
assert_nothing_raised() {
- server = Puppet::Network::HTTPServer::WEBrick.new(
+
+ server = Puppet::Network::HTTPServer::WEBrick.new(
+
:Port => @@port,
+
:Handlers => {
:CA => {}, # so that certs autogenerate
:Status => nil
diff --git a/test/network/xmlrpc/processor.rb b/test/network/xmlrpc/processor.rb
index 079194efa..0b0646728 100755
--- a/test/network/xmlrpc/processor.rb
+++ b/test/network/xmlrpc/processor.rb
@@ -65,8 +65,7 @@ class TestXMLRPCProcessor < Test::Unit::TestCase
request.expects(:method=).with("mymethod")
@processor.stubs(:verify)
- @processor.expects(:handle).with(request.call,
- "params", request.name, request.ip)
+ @processor.expects(:handle).with(request.call, "params", request.name, request.ip)
@processor.send(:process, ["myhandler.mymethod", ["params"]], request)
end
diff --git a/test/network/xmlrpc/server.rb b/test/network/xmlrpc/server.rb
index ae9f17ddf..88652a261 100755
--- a/test/network/xmlrpc/server.rb
+++ b/test/network/xmlrpc/server.rb
@@ -18,8 +18,7 @@ class TestXMLRPCServer < Test::Unit::TestCase
assert(@server.get_service_hook, "no service hook defined")
assert_nothing_raised("Did not init @loadedhandlers") do
- assert(! @server.handler_loaded?(:puppetca),
- "server thinks handlers are loaded")
+ assert(! @server.handler_loaded?(:puppetca), "server thinks handlers are loaded")
end
end
end
diff --git a/test/network/xmlrpc/webrick_servlet.rb b/test/network/xmlrpc/webrick_servlet.rb
index 1d83d36ad..d3daa4c0d 100755
--- a/test/network/xmlrpc/webrick_servlet.rb
+++ b/test/network/xmlrpc/webrick_servlet.rb
@@ -24,7 +24,10 @@ class TestXMLRPCWEBrickServlet < Test::Unit::TestCase
assert(servlet.get_service_hook, "service hook was not set up")
- assert(servlet.handler_loaded?(:puppetca),
+
+ assert(
+ servlet.handler_loaded?(:puppetca),
+
"Did not load handler")
end
end
diff --git a/test/other/relationships.rb b/test/other/relationships.rb
index e9d3a9376..abdb537a3 100755
--- a/test/other/relationships.rb
+++ b/test/other/relationships.rb
@@ -14,8 +14,11 @@ class TestRelationships < Test::Unit::TestCase
def newfile
assert_nothing_raised() {
- return Puppet::Type.type(:file).new(
+
+ return Puppet::Type.type(:file).new(
+
:path => tempfile,
+
:check => [:mode, :owner, :group]
)
}
@@ -39,8 +42,7 @@ class TestRelationships < Test::Unit::TestCase
sources.each do |source|
targets.each do |target|
edge = deps.find { |e| e.source == source and e.target == target }
- assert(edge, "Could not find edge for %s => %s" %
- [source.ref, target.ref])
+ assert(edge, "Could not find edge for %s => %s" % [source.ref, target.ref])
if refresher
assert_equal(:ALL_EVENTS, edge.event)
@@ -57,9 +59,15 @@ class TestRelationships < Test::Unit::TestCase
# We know that execs autorequire their cwd, so we'll use that
path = tempfile()
- file = Puppet::Type.type(:file).new(:title => "myfile", :path => path,
+
+ file = Puppet::Type.type(:file).new(
+ :title => "myfile", :path => path,
+
:ensure => :directory)
- exec = Puppet::Type.newexec(:title => "myexec", :cwd => path,
+
+ exec = Puppet::Type.newexec(
+ :title => "myexec", :cwd => path,
+
:command => "/bin/echo")
catalog = mk_catalog(file, exec)
diff --git a/test/other/report.rb b/test/other/report.rb
index 9e0a9bbbe..af9ecea81 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -21,8 +21,11 @@ class TestReports < Test::Unit::TestCase
# Make every third file
File.open(file, "w") { |f| f.puts "" } if i % 3 == 0
- objects << Puppet::Type.type(:file).new(
+
+ objects << Puppet::Type.type(:file).new(
+
:path => file,
+
:ensure => "file"
)
end
@@ -124,8 +127,7 @@ class TestReports < Test::Unit::TestCase
assert(FileTest.exists?(file), "Did not create rrd file for %s" % type)
daily = file.sub ".rrd", "-daily.png"
- assert(FileTest.exists?(daily),
- "Did not make daily graph for %s" % type)
+ assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type)
end
end
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 5c21755fb..5c73f1b9d 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -146,8 +146,7 @@ class TestTransactions < Test::Unit::TestCase
end
%w{ya ra y r}.each do |name|
- assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]),
- "Generated %s was not a vertex" % name)
+ assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]), "Generated %s was not a vertex" % name)
assert($finished.include?(name), "%s was not finished" % name)
end
end
@@ -323,13 +322,22 @@ class TestTransactions < Test::Unit::TestCase
path = tempfile
epath = tempfile
spath = tempfile
- file = Puppet::Type.type(:file).new(:path => path, :ensure => :file,
+
+ file = Puppet::Type.type(:file).new(
+ :path => path, :ensure => :file,
+
:title => "file")
- exec = Puppet::Type.type(:exec).new(:command => "touch %s" % epath,
+
+ exec = Puppet::Type.type(:exec).new(
+ :command => "touch %s" % epath,
:path => ENV["PATH"], :subscribe => file, :refreshonly => true,
+
:title => 'exec1')
- exec2 = Puppet::Type.type(:exec).new(:command => "touch %s" % spath,
+
+ exec2 = Puppet::Type.type(:exec).new(
+ :command => "touch %s" % spath,
:path => ENV["PATH"], :subscribe => exec, :refreshonly => true,
+
:title => 'exec2')
Puppet[:noop] = true
@@ -347,11 +355,17 @@ class TestTransactions < Test::Unit::TestCase
assert(@logs.detect { |l|
l.message =~ /should be/ and l.source == file.property(:ensure).path},
"did not log file change")
- assert(@logs.detect { |l|
+
+ assert(
+ @logs.detect { |l|
l.message =~ /Would have/ and l.source == exec.path },
+
"did not log first exec trigger")
- assert(@logs.detect { |l|
+
+ assert(
+ @logs.detect { |l|
l.message =~ /Would have/ and l.source == exec2.path },
+
"did not log second exec trigger")
end
@@ -361,7 +375,10 @@ class TestTransactions < Test::Unit::TestCase
3.times do |i|
path = tempfile
paths << path
- file = Puppet::Type.type(:file).new(:path => path, :ensure => :absent,
+
+ file = Puppet::Type.type(:file).new(
+ :path => path, :ensure => :absent,
+
:backup => false, :title => "file%s" % i)
File.open(path, "w") { |f| f.puts "" }
files << file
diff --git a/test/puppet/defaults.rb b/test/puppet/defaults.rb
index bab6644d2..86c67e0be 100755
--- a/test/puppet/defaults.rb
+++ b/test/puppet/defaults.rb
@@ -49,8 +49,7 @@ class TestPuppetDefaults < Test::Unit::TestCase
value = Puppet[param]
unless value !~ notval
- assert_nothing_raised { raise "%s is incorrectly set to %s" %
- [param,value] }
+ assert_nothing_raised { raise "%s is incorrectly set to %s" % [param,value] }
end
}
end
diff --git a/test/puppet/tc_suidmanager.rb b/test/puppet/tc_suidmanager.rb
index 2075427f8..0d51ddacd 100755
--- a/test/puppet/tc_suidmanager.rb
+++ b/test/puppet/tc_suidmanager.rb
@@ -81,16 +81,19 @@ class TestSUIDManager < Test::Unit::TestCase
else
set_exit_status!
- Puppet::Util.expects(:execute).with( 'yay',
- { :failonfail => false,
- :uid => @user.uid,
- :gid => @user.gid }
- ).returns('output')
+
+ Puppet::Util.expects(:execute).with(
+ 'yay',
+ { :failonfail => false,
+ :uid => @user.uid,
+
+ :gid => @user.gid }
+ ).returns('output')
output = Puppet::Util::SUIDManager.run_and_capture 'yay',
- @user.uid,
- @user.gid
+ @user.uid,
+ @user.gid
assert_equal 'output', output.first
assert_kind_of Process::Status, output.last
@@ -119,8 +122,8 @@ class TestSUIDManager < Test::Unit::TestCase
end
def set_exit_status!
- # We want to make sure $? is set, this is the only way I know how.
- Kernel.system '' if $?.nil?
+ # We want to make sure $? is set, this is the only way I know how.
+ Kernel.system '' if $?.nil?
end
end
diff --git a/test/rails/railsparameter.rb b/test/rails/railsparameter.rb
index 60bbdc06c..73d6ab664 100755
--- a/test/rails/railsparameter.rb
+++ b/test/rails/railsparameter.rb
@@ -28,10 +28,13 @@ class TestRailsParameter < Test::Unit::TestCase
host.save
- resource = host.resources.create(
- :title => "/tmp/to_resource",
- :restype => "file",
- :exported => true)
+
+ resource = host.resources.create(
+
+ :title => "/tmp/to_resource",
+ :restype => "file",
+
+ :exported => true)
# Use array and non-array values, to make sure we get things back in
# the same form.
@@ -43,8 +46,11 @@ class TestRailsParameter < Test::Unit::TestCase
values = [value]
end
valueobjects = values.collect do |v|
- resource.param_values.create(:value => v,
- :param_name => param)
+
+ resource.param_values.create(
+ :value => v,
+
+ :param_name => param)
end
assert(param, "Did not create rails parameter")
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
diff --git a/test/util/classgen.rb b/test/util/classgen.rb
index 24908069d..83b64813c 100755
--- a/test/util/classgen.rb
+++ b/test/util/classgen.rb
@@ -55,14 +55,20 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
# Now make sure we can choose our own constant
assert_nothing_raised do
- const = sub.send(:handleclassconst, newklass, klass.name,
+
+ const = sub.send(
+ :handleclassconst, newklass, klass.name,
+
:constant => "Fooness")
end
assert(defined?(Baseconst::Fooness), "Specified constant was not defined")
# And make sure prefixes work
assert_nothing_raised do
- const = sub.send(:handleclassconst, newklass, klass.name,
+
+ const = sub.send(
+ :handleclassconst, newklass, klass.name,
+
:prefix => "Test")
end
assert(defined?(Baseconst::TestGenconst), "prefix was not used")
@@ -111,7 +117,10 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
assert(!klass.one, "'one' was already set")
- assert_nothing_raised do sub.send(:initclass, klass,
+
+ assert_nothing_raised do sub.send(
+ :initclass, klass,
+
:attributes => {:one => :a, :two => :b}) end
assert_equal(:a, klass.one, "Class was initialized incorrectly")
@@ -135,7 +144,10 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
assert(! klass.respond_to?(:extended), "Class already responds to extended")
assert(! klass.new.respond_to?(:included), "Class already responds to included")
- assert_nothing_raised do sub.send(:initclass, klass,
+
+ assert_nothing_raised do sub.send(
+ :initclass, klass,
+
:include => incl, :extend => ext)
end
@@ -150,8 +162,7 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
name = "yayness"
klass = nil
assert_nothing_raised {
- klass = GenTest.genclass(name, :array => array,
- :hash => hash, :parent => FakeBase) do
+ klass = GenTest.genclass(name, :array => array, :hash => hash, :parent => FakeBase) do
class << self
attr_accessor :name
end
@@ -160,9 +171,15 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
assert(klass.respond_to?(:name=), "Class did not execute block")
- assert(hash.include?(klass.name),
+
+ assert(
+ hash.include?(klass.name),
+
"Class did not get added to hash")
- assert(array.include?(klass),
+
+ assert(
+ array.include?(klass),
+
"Class did not get added to array")
assert_equal(klass.superclass, FakeBase, "Parent class was wrong")
end
@@ -209,10 +226,8 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase
assert(mod.respond_to?(:yaytest), "Class did not execute block")
assert_instance_of(Module, mod)
- assert(hash.include?(mod.name),
- "Class did not get added to hash")
- assert(array.include?(mod),
- "Class did not get added to array")
+ assert(hash.include?(mod.name), "Class did not get added to hash")
+ assert(array.include?(mod), "Class did not get added to array")
end
def test_genconst_string
diff --git a/test/util/fileparsing.rb b/test/util/fileparsing.rb
index c88bcb23a..097254a50 100755
--- a/test/util/fileparsing.rb
+++ b/test/util/fileparsing.rb
@@ -21,21 +21,22 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
def test_lines
- assert_equal("\n", @parser.line_separator,
- "Default separator was incorrect")
+ assert_equal("\n", @parser.line_separator, "Default separator was incorrect")
{"\n" => ["one two\nthree four", "one two\nthree four\n"],
- "\t" => ["one two\tthree four", "one two\tthree four\t"],
+ "\t" => ["one two\tthree four", "one two\tthree four\t"],
}.each do |sep, tests|
assert_nothing_raised do
@parser.line_separator = sep
end
- assert_equal(sep, @parser.line_separator,
- "Did not set separator")
+
+ assert_equal(
+ sep, @parser.line_separator,
+
+ "Did not set separator")
tests.each do |test|
- assert_equal(["one two", "three four"], @parser.lines(test),
- "Incorrectly parsed %s" % test.inspect)
+ assert_equal(["one two", "three four"], @parser.lines(test), "Incorrectly parsed %s" % test.inspect)
end
end
end
@@ -72,8 +73,11 @@ class TestUtilFileParsing < Test::Unit::TestCase
# Make sure it matches
assert_nothing_raised do
- assert_equal({:record_type => :comment, :line => comment},
- @parser.parse_line(comment))
+
+ assert_equal(
+ {:record_type => :comment, :line => comment},
+
+ @parser.parse_line(comment))
end
# But not something else
@@ -88,14 +92,20 @@ class TestUtilFileParsing < Test::Unit::TestCase
# The comment should still match
assert_nothing_raised do
- assert_equal({:record_type => :comment, :line => comment},
- @parser.parse_line(comment))
+
+ assert_equal(
+ {:record_type => :comment, :line => comment},
+
+ @parser.parse_line(comment))
end
# As should our new line type
assert_nothing_raised do
- assert_equal({:record_type => :blank, :line => ""},
- @parser.parse_line(""))
+
+ assert_equal(
+ {:record_type => :blank, :line => ""},
+
+ @parser.parse_line(""))
end
end
@@ -141,13 +151,11 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
assert_nothing_raised("Did not parse old comment") do
- assert_equal({:record_type => :comment, :line => comment},
- @parser.parse_line(comment))
+ assert_equal({:record_type => :comment, :line => comment}, @parser.parse_line(comment))
end
comment = '" another type of comment'
assert_nothing_raised("Did not parse new comment") do
- assert_equal({:record_type => :comment2, :line => comment},
- @parser.parse_line(comment))
+ assert_equal({:record_type => :comment2, :line => comment}, @parser.parse_line(comment))
end
# Now define two overlapping record types and make sure we keep the
@@ -158,8 +166,7 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
assert_nothing_raised do
- assert_equal({:record_type => :one, :line => "yayness"},
- @parser.parse_line("yayness"))
+ assert_equal({:record_type => :one, :line => "yayness"}, @parser.parse_line("yayness"))
end
end
@@ -182,8 +189,7 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
# Make sure out tab line gets matched
- tabshould = {:record_type => :tabs, :name => "tab", :first => "separated",
- :second => "content"}
+ tabshould = {:record_type => :tabs, :name => "tab", :first => "separated", :second => "content"}
assert_nothing_raised do
assert_equal(tabshould, @parser.handle_record_line(tabrecord, tabs))
end
@@ -195,8 +201,7 @@ class TestUtilFileParsing < Test::Unit::TestCase
end
# Now make sure both lines parse correctly
- spaceshould = {:record_type => :spaces, :name => "space",
- :first => "separated", :second => "content"}
+ spaceshould = {:record_type => :spaces, :name => "space", :first => "separated", :second => "content"}
assert_nothing_raised do
assert_equal(tabshould, @parser.handle_record_line(tabrecord, tabs))
@@ -243,8 +248,7 @@ class TestUtilFileParsing < Test::Unit::TestCase
ordered_records = order.collect { |name| records[name] }
# Make sure we default to a trailing separator
- assert_equal(true, @parser.trailing_separator,
- "Did not default to a trailing separtor")
+ assert_equal(true, @parser.trailing_separator, "Did not default to a trailing separtor")
# Start without a trailing separator
@parser.trailing_separator = false
@@ -280,7 +284,10 @@ class TestUtilFileParsing < Test::Unit::TestCase
result = nil
assert_nothing_raised do
- result = @parser.to_line(:record_type => :record,
+
+ result = @parser.to_line(
+ :record_type => :record,
+
:one => "a", :two => :absent, :three => "b")
end
@@ -289,15 +296,17 @@ class TestUtilFileParsing < Test::Unit::TestCase
# Now try using a different replacement character
record.absent = "*" # Because cron is a pain in my ass
assert_nothing_raised do
- result = @parser.to_line(:record_type => :record,
- :one => "a", :two => :absent, :three => "b")
+ result = @parser.to_line(:record_type => :record, :one => "a", :two => :absent, :three => "b")
end
assert_equal("a * b", result, "Absent was not correctly replaced")
# Make sure we deal correctly with the string 'absent'
assert_nothing_raised do
- result = @parser.to_line(:record_type => :record,
+
+ result = @parser.to_line(
+ :record_type => :record,
+
:one => "a", :two => "b", :three => 'absent')
end
@@ -305,7 +314,10 @@ class TestUtilFileParsing < Test::Unit::TestCase
# And, of course, make sure we can swap things around.
assert_nothing_raised do
- result = @parser.to_line(:record_type => :record,
+
+ result = @parser.to_line(
+ :record_type => :record,
+
:one => "a", :two => "b", :three => :absent)
end
@@ -318,14 +330,15 @@ class TestUtilFileParsing < Test::Unit::TestCase
# Check parsing first
result = @parser.parse_line(start)
[:one, :two].each do |param|
- assert_equal(record[param], result[param],
+
+ assert_equal(
+ record[param], result[param],
+
"Did not correctly parse %s" % start.inspect)
end
# And generating
- assert_equal(final, @parser.to_line(result),
- "Did not correctly generate %s from %s" %
- [final.inspect, record.inspect])
+ assert_equal(final, @parser.to_line(result), "Did not correctly generate %s from %s" % [final.inspect, record.inspect])
end
# First try it with symmetric characters
@@ -361,23 +374,32 @@ class TestUtilFileParsing < Test::Unit::TestCase
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")
+# 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
@parser.record_line :record, :fields => %w{one two three}
- assert(@parser.valid_attr?(:record, :one),
+
+ assert(
+ @parser.valid_attr?(:record, :one),
+
"one was considered invalid")
- assert(@parser.valid_attr?(:record, :ensure),
+
+ assert(
+ @parser.valid_attr?(:record, :ensure),
+
"ensure was considered invalid")
- assert(! @parser.valid_attr?(:record, :four),
+
+ assert(
+ ! @parser.valid_attr?(:record, :four),
+
"four was considered valid")
end
@@ -433,11 +455,9 @@ billy three four\n"
assert(result, "Did not get a result back for '%s'" % line)
should.each do |field|
if field == :alias and line =~ /null/
- assert_equal(%w{sink null}, result[field],
- "Field %s was not right in '%s'" % [field, line])
+ assert_equal(%w{sink null}, result[field], "Field %s was not right in '%s'" % [field, line])
else
- assert_equal(values[field], result[field],
- "Field %s was not right in '%s'" % [field, line])
+ assert_equal(values[field], result[field], "Field %s was not right in '%s'" % [field, line])
end
end
end
@@ -457,9 +477,9 @@ billy three four\n"
end
{ "a b c d" => [],
- "a b * d" => [:three],
- "a b * *" => [:three, :four],
- "a b c *" => [:four]
+ "a b * d" => [:three],
+ "a b * *" => [:three, :four],
+ "a b c *" => [:four]
}.each do |line, absentees|
record = nil
assert_nothing_raised do
@@ -495,7 +515,10 @@ billy three four\n"
:optional => %w{three four}
end
- assert_equal("a b ",
+
+ assert_equal(
+ "a b ",
+
@parser.to_line(:record_type => :record, :one => "a", :two => "b")
)
@@ -508,7 +531,10 @@ billy three four\n"
:rts => true
end
- assert_equal("a b",
+
+ assert_equal(
+ "a b",
+
@parser.to_line(:record_type => :record, :one => "a", :two => "b")
)
@@ -522,7 +548,10 @@ billy three four\n"
:rts => /[ *]+$/
end
- assert_equal("a b",
+
+ assert_equal(
+ "a b",
+
@parser.to_line(:record_type => :record, :one => "a", :two => "b")
)
end
@@ -536,7 +565,10 @@ billy three four\n"
assert_nothing_raised do
result = @parser.send(:parse_line, "Name One Two Three")
end
- assert_equal("Two Three", result[:two],
+
+ assert_equal(
+ "Two Three", result[:two],
+
"Did not roll up last fields by default")
@parser = FParser.new
@@ -548,7 +580,10 @@ billy three four\n"
assert_nothing_raised do
result = @parser.send(:parse_line, "Name One Two Three")
end
- assert_equal("Two", result[:two],
+
+ assert_equal(
+ "Two", result[:two],
+
"Rolled up last fields when rollup => false")
end
@@ -560,7 +595,10 @@ billy three four\n"
end
end
- assert(record.respond_to?(:process),
+
+ assert(
+ record.respond_to?(:process),
+
"Block was not used with text line")
assert_equal("YAYNESS", record.process("yayness")[:line],
@@ -616,8 +654,7 @@ class TestUtilFileRecord < Test::Unit::TestCase
assert_nothing_raised do
record = Record.new(:record, :fields => %w{one two})
end
- assert_equal([:one, :two], record.fields,
- "Did not symbolize fields")
+ assert_equal([:one, :two], record.fields, "Did not symbolize fields")
# Make sure we fail on invalid fields
[:record_type, :target, :on_disk].each do |field|
@@ -634,9 +671,8 @@ class TestUtilFileRecord < Test::Unit::TestCase
end
record = Record.new(:record, :fields => %w{fields})
- {:absent => "", :separator => /\s+/, :joiner => " ",
- :optional => []}.each do |field, default|
- assert_equal(default, record.send(field), "%s was not default" % field)
+ {:absent => "", :separator => /\s+/, :joiner => " ", :optional => []}.each do |field, default|
+ assert_equal(default, record.send(field), "%s was not default" % field)
end
end
@@ -650,10 +686,16 @@ class TestUtilFileRecord < Test::Unit::TestCase
line = "This is a line"
- assert(record.respond_to?(:process),
+
+ assert(
+ record.respond_to?(:process),
+
"Record did not define :process method")
- assert_equal(line.upcase, record.process(line),
+
+ assert_equal(
+ line.upcase, record.process(line),
+
"Record did not process line correctly")
end
diff --git a/test/util/inifile.rb b/test/util/inifile.rb
index 8ce52ee8d..b4d7f9353 100755
--- a/test/util/inifile.rb
+++ b/test/util/inifile.rb
@@ -29,22 +29,28 @@ class TestFileType < Test::Unit::TestCase
@file['main']['key2'] = 'newvalue2'
@file['main']['key3'] = 'newvalue3'
text = s.format
- assert_equal("[main]\nkey1=value1\n# Comment\nkey2=newvalue2\nkey3=newvalue3\n",
- s.format)
+
+ assert_equal(
+ "[main]\nkey1=value1\n# Comment\nkey2=newvalue2\nkey3=newvalue3\n",
+
+ s.format)
end
def test_multi
fmain = mkfile("[main]\nkey1=main.value1\n# Comment\nkey2=main.value2")
fsub = mkfile("[sub1]\nkey1=sub1 value1\n\n" +
- "[sub2]\nkey1=sub2.value1")
+ "[sub2]\nkey1=sub2.value1")
main_mtime = File::stat(fmain).mtime
assert_nothing_raised {
@file.read(fmain)
@file.read(fsub)
}
main = get_section('main')
- assert_entries(main,
- { 'key1' => 'main.value1', 'key2' => 'main.value2' })
+
+ assert_entries(
+ main,
+
+ { 'key1' => 'main.value1', 'key2' => 'main.value2' })
sub1 = get_section('sub1')
assert_entries(sub1, { 'key1' => 'sub1 value1' })
sub2 = get_section('sub2')
@@ -60,14 +66,17 @@ class TestFileType < Test::Unit::TestCase
assert( File.exists?(fsub) )
assert_equal(main_mtime, File::stat(fmain).mtime)
subtext = File.read(fsub)
- assert_equal("[sub1]\nkey1=sub1 newvalue1\n\n" +
- "[sub2]\nkey1=sub2.value1\nkey2=sub2 newvalue2\n",
- subtext)
+
+ assert_equal(
+ "[sub1]\nkey1=sub1 newvalue1\n\n" +
+ "[sub2]\nkey1=sub2.value1\nkey2=sub2 newvalue2\n",
+
+ subtext)
end
def test_format_nil
fname = mkfile("[main]\nkey1=value1\n# Comment\nkey2=value2\n" +
- "# Comment2\n")
+ "# Comment2\n")
assert_nothing_raised {
@file.read(fname)
}
@@ -75,8 +84,11 @@ class TestFileType < Test::Unit::TestCase
s['key2'] = nil
s['key3'] = nil
text = s.format
- assert_equal("[main]\nkey1=value1\n# Comment\n# Comment2\n",
- s.format)
+
+ assert_equal(
+ "[main]\nkey1=value1\n# Comment\n# Comment2\n",
+
+ s.format)
end
def test_whitespace
@@ -107,9 +119,12 @@ class TestFileType < Test::Unit::TestCase
def assert_entries(section, hash)
hash.each do |k, v|
- assert_equal(v, section[k],
- "Expected <#{v}> for #{section.name}[#{k}] " +
- "but got <#{section[k]}>")
+
+ assert_equal(
+ v, section[k],
+
+ "Expected <#{v}> for #{section.name}[#{k}] " +
+ "but got <#{section[k]}>")
end
end
diff --git a/test/util/log.rb b/test/util/log.rb
index b28d601e9..5fb30cf05 100755
--- a/test/util/log.rb
+++ b/test/util/log.rb
@@ -35,9 +35,12 @@ class TestLog < Test::Unit::TestCase
levels.collect { |level|
next if level == :alert
assert_nothing_raised() {
- Puppet::Util::Log.new(
+
+ Puppet::Util::Log.new(
+
:level => level,
:source => "Test",
+
:message => "Unit test for %s" % level
)
}
@@ -118,8 +121,11 @@ class TestLog < Test::Unit::TestCase
Puppet::Util::Log.newdestination :syslog
assert_nothing_raised {
- Puppet::Util::Log.new(
+
+ Puppet::Util::Log.new(
+
:level => :info,
+
:message => "A message with %s in it"
)
}
@@ -128,8 +134,11 @@ class TestLog < Test::Unit::TestCase
# Verify that the error and source are always strings
def test_argsAreStrings
msg = nil
- file = Puppet::Type.type(:file).new(
+
+ file = Puppet::Type.type(:file).new(
+
:path => tempfile(),
+
:check => %w{owner group}
)
assert_nothing_raised {
@@ -169,11 +178,9 @@ class TestLog < Test::Unit::TestCase
Puppet::Util::Log.close(:console)
Puppet::Util::Log.newdestination(file)
Puppet.warning "A test"
- assert(File.read(file) !~ /A test/,
- "File defualted to autoflush")
+ assert(File.read(file) !~ /A test/, "File defualted to autoflush")
Puppet::Util::Log.flush
- assert(File.read(file) =~ /A test/,
- "File did not flush")
+ assert(File.read(file) =~ /A test/, "File did not flush")
Puppet::Util::Log.close(file)
# Now try one with autoflush enabled
@@ -181,8 +188,7 @@ class TestLog < Test::Unit::TestCase
file = tempfile
Puppet::Util::Log.newdestination(file)
Puppet.warning "A test"
- assert(File.read(file) =~ /A test/,
- "File did not autoflush")
+ assert(File.read(file) =~ /A test/, "File did not autoflush")
Puppet::Util::Log.close(file)
end
@@ -206,8 +212,7 @@ class TestLog < Test::Unit::TestCase
# Now reopen the log
Puppet::Util::Log.reopen
Puppet.warning "Reopen test"
- assert(File.read(file) =~ /Reopen test/,
- "File did not reopen")
+ assert(File.read(file) =~ /Reopen test/, "File did not reopen")
Puppet::Util::Log.close(file)
end
end
diff --git a/test/util/package.rb b/test/util/package.rb
index b77850d4b..c252db1d8 100755
--- a/test/util/package.rb
+++ b/test/util/package.rb
@@ -11,8 +11,7 @@ class TestPuppetUtilPackage < Test::Unit::TestCase
include Puppet::Util::Package
def test_versioncmp
- ary = %w{ 1.1.6 2.3 1.1a 3.0 1.5 1 2.4 1.1-4
- 2.3.1 1.2 2.3.0 1.1-3 2.4b 2.4 2.40.2 2.3a.1 3.1 0002 1.1-5 1.1.a 1.06}
+ ary = %w{ 1.1.6 2.3 1.1a 3.0 1.5 1 2.4 1.1-4 2.3.1 1.2 2.3.0 1.1-3 2.4b 2.4 2.40.2 2.3a.1 3.1 0002 1.1-5 1.1.a 1.06}
newary = nil
assert_nothing_raised do
diff --git a/test/util/settings.rb b/test/util/settings.rb
index 272ced9f5..354a5d7fc 100755
--- a/test/util/settings.rb
+++ b/test/util/settings.rb
@@ -20,17 +20,23 @@ class TestSettings < Test::Unit::TestCase
def set_configs(config = nil)
config ||= @config
- config.setdefaults("main",
+
+ config.setdefaults(
+ "main",
:one => ["a", "one"],
:two => ["a", "two"],
:yay => ["/default/path", "boo"],
:mkusers => [true, "uh, yeah"],
+
:name => ["testing", "a"]
)
- config.setdefaults("section1",
+
+ config.setdefaults(
+ "section1",
:attr => ["a", "one"],
:attrdir => ["/another/dir", "two"],
+
:attr3 => ["$attrdir/maybe", "boo"]
)
end
@@ -183,13 +189,13 @@ class TestSettings < Test::Unit::TestCase
def test_parse_file
text = %{
-one = this is a test
-two = another test
-owner = root
-group = root
-yay = /a/path
+ one = this is a test
+ two = another test
+ owner = root
+ group = root
+ yay = /a/path
-[main]
+ [main]
four = five
six = seven
@@ -241,10 +247,13 @@ yay = /a/path
c = mkconfig
assert_nothing_raised {
- @config.setdefaults("testing",
+
+ @config.setdefaults(
+ "testing",
:onboolean => [true, "An on bool"],
:offboolean => [false, "An off bool"],
:string => ["a string", "A string arg"],
+
:file => ["/path/to/file", "A file arg"]
)
}
@@ -270,8 +279,7 @@ yay = /a/path
arg = val
end
- assert_nothing_raised("Could not handle arg %s with value %s" %
- [opt, val]) {
+ assert_nothing_raised("Could not handle arg %s with value %s" % [opt, val]) {
@config.handlearg(opt, arg)
}
@@ -280,12 +288,15 @@ yay = /a/path
end
def test_addargs
- @config.setdefaults("testing",
- :onboolean => [true, "An on bool"],
- :offboolean => [false, "An off bool"],
- :string => ["a string", "A string arg"],
- :file => ["/path/to/file", "A file arg"]
- )
+
+ @config.setdefaults(
+ "testing",
+ :onboolean => [true, "An on bool"],
+ :offboolean => [false, "An off bool"],
+ :string => ["a string", "A string arg"],
+
+ :file => ["/path/to/file", "A file arg"]
+ )
should = []
@config.each { |name, element|
@@ -303,10 +314,13 @@ yay = /a/path
def test_addargs_functional
@config = Puppet::Util::Settings.new
- @config.setdefaults("testing",
- :onboolean => [true, "An on bool"],
- :string => ["a string", "A string arg"]
- )
+
+ @config.setdefaults(
+ "testing",
+ :onboolean => [true, "An on bool"],
+
+ :string => ["a string", "A string arg"]
+ )
result = []
should = []
assert_nothing_raised("Add args failed") do
@@ -430,7 +444,10 @@ yay = /a/path
config = mkconfig
file = tempfile()
- config.setdefaults(:mysection,
+
+ config.setdefaults(
+ :mysection,
+
:mydir => [file, "a file"]
)
@@ -442,7 +459,10 @@ yay = /a/path
assert(FileTest.directory?(file), "Directory did not get created")
- assert_equal("yayness", Puppet[:tags],
+
+ assert_equal(
+ "yayness", Puppet[:tags],
+
"Tags got changed during config")
end
@@ -457,7 +477,10 @@ yay = /a/path
val = config[:url]
}
- assert_equal("http://yayness/rahness", val,
+
+ assert_equal(
+ "http://yayness/rahness", val,
+
"Settings got messed up")
end
@@ -485,8 +508,11 @@ yay = /a/path
}
elem = config.setting(name)
- assert_instance_of(type, elem,
- "%s got created as wrong type" % value.inspect)
+
+ assert_instance_of(
+ type, elem,
+
+ "%s got created as wrong type" % value.inspect)
end
end
@@ -506,12 +532,12 @@ yay = /a/path
none = one
middle = mid"quote
}
- }
+ }
- config.setdefaults(:mysection, :config => [file, "eh"])
+ config.setdefaults(:mysection, :config => [file, "eh"])
- assert_nothing_raised {
- config.parse
+ assert_nothing_raised {
+ config.parse
}
%w{singleq doubleq none}.each do |p|
@@ -574,8 +600,11 @@ yay = /a/path
def test_no_modify_root
config = mkconfig
- config.setdefaults(:yay,
+
+ config.setdefaults(
+ :yay,
:mydir => {:default => tempfile(),
+
:mode => 0644,
:owner => "root",
:group => "service",
@@ -643,25 +672,37 @@ yay = /a/path
end
def test_multiple_interpolations
- @config.setdefaults(:section,
+
+ @config.setdefaults(
+ :section,
:one => ["oneval", "yay"],
:two => ["twoval", "yay"],
+
:three => ["$one/$two", "yay"]
)
- assert_equal("oneval/twoval", @config[:three],
+
+ assert_equal(
+ "oneval/twoval", @config[:three],
+
"Did not interpolate multiple variables")
end
# Make sure we can replace ${style} var names
def test_curly_replacements
- @config.setdefaults(:section,
+
+ @config.setdefaults(
+ :section,
:one => ["oneval", "yay"],
:two => ["twoval", "yay"],
+
:three => ["$one/${two}/${one}/$two", "yay"]
)
- assert_equal("oneval/twoval/oneval/twoval", @config[:three],
+
+ assert_equal(
+ "oneval/twoval/oneval/twoval", @config[:three],
+
"Did not interpolate curlied variables")
end
@@ -682,16 +723,25 @@ yay = /a/path
def test_celement_short_name_not_duplicated
config = mkconfig
assert_nothing_raised("Could not create celement with short name.") do
- config.setdefaults(:main,
- :one => { :default => "blah", :desc => "anything", :short => "o" })
+
+ config.setdefaults(
+ :main,
+
+ :one => { :default => "blah", :desc => "anything", :short => "o" })
end
assert_nothing_raised("Could not create second celement with short name.") do
- config.setdefaults(:main,
- :two => { :default => "blah", :desc => "anything", :short => "i" })
+
+ config.setdefaults(
+ :main,
+
+ :two => { :default => "blah", :desc => "anything", :short => "i" })
end
assert_raise(ArgumentError, "Could create second celement with duplicate short name.") do
- config.setdefaults(:main,
- :three => { :default => "blah", :desc => "anything", :short => "i" })
+
+ config.setdefaults(
+ :main,
+
+ :three => { :default => "blah", :desc => "anything", :short => "i" })
end
# make sure that when the above raises an expection that the config is not included
assert(!config.include?(:three), "Invalid configuration item was retained")
@@ -706,12 +756,18 @@ yay = /a/path
assert_equal([["--foo", "-n", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")
element = BooleanSetting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new
- assert_equal([["--foo", GetoptLong::NO_ARGUMENT], ["--no-foo", GetoptLong::NO_ARGUMENT]],
- element.getopt_args, "Did not produce appropriate getopt args")
+
+ assert_equal(
+ [["--foo", GetoptLong::NO_ARGUMENT], ["--no-foo", GetoptLong::NO_ARGUMENT]],
+
+ element.getopt_args, "Did not produce appropriate getopt args")
element.short = "n"
- assert_equal([["--foo", "-n", GetoptLong::NO_ARGUMENT],["--no-foo", GetoptLong::NO_ARGUMENT]],
- element.getopt_args, "Did not produce appropriate getopt args")
+
+ assert_equal(
+ [["--foo", "-n", GetoptLong::NO_ARGUMENT],["--no-foo", GetoptLong::NO_ARGUMENT]],
+
+ element.getopt_args, "Did not produce appropriate getopt args")
end
end
diff --git a/test/util/storage.rb b/test/util/storage.rb
index b0efff317..2259a59d2 100755
--- a/test/util/storage.rb
+++ b/test/util/storage.rb
@@ -12,8 +12,11 @@ class TestStorage < Test::Unit::TestCase
path = tempfile()
File.open(path, "w") { |f| f.puts :yayness }
- f = Puppet::Type.type(:file).new(
+
+ f = Puppet::Type.type(:file).new(
+
:name => path,
+
:check => %w{checksum type}
)
diff --git a/test/util/subclass_loader.rb b/test/util/subclass_loader.rb
index 0efd636f4..ca2522dbf 100755
--- a/test/util/subclass_loader.rb
+++ b/test/util/subclass_loader.rb
@@ -15,7 +15,7 @@ class TestPuppetUtilSubclassLoader < Test::Unit::TestCase
def mk_subclass(name, path, parent)
# Make a fake client
- unless defined? @basedir
+ unless defined?(@basedir)
@basedir ||= tempfile()
$: << @basedir
cleanup { $:.delete(@basedir) if $:.include?(@basedir) }
@@ -40,8 +40,7 @@ class TestPuppetUtilSubclassLoader < Test::Unit::TestCase
fake = LoadTest.faker(:fake)
end
assert_nothing_raised do
- assert_equal(fake, LoadTest.fake,
- "Did not get subclass back from main method")
+ assert_equal(fake, LoadTest.fake, "Did not get subclass back from main method")
end
assert(fake, "did not load subclass")
@@ -83,10 +82,8 @@ class TestPuppetUtilSubclassLoader < Test::Unit::TestCase
end
assert(othersub, "did not get other sub")
assert(mainsub, "did not get main sub")
- assert(othersub.ancestors.include?(OtherLoader),
- "othersub is not a subclass of otherloader")
- assert(mainsub.ancestors.include?(LoadTest),
- "mainsub is not a subclass of loadtest")
+ assert(othersub.ancestors.include?(OtherLoader), "othersub is not a subclass of otherloader")
+ assert(mainsub.ancestors.include?(LoadTest), "mainsub is not a subclass of loadtest")
end
end
diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb
index 62179084f..82016f3aa 100755
--- a/test/util/utiltest.rb
+++ b/test/util/utiltest.rb
@@ -78,8 +78,7 @@ class TestPuppetUtil < Test::Unit::TestCase
end
[:yay, "cool"].each do |var|
- assert_equal(inst.hash[var], inst[var],
- "Var %s did not take" % var)
+ assert_equal(inst.hash[var], inst[var], "Var %s did not take" % var)
end
assert_nothing_raised do
@@ -88,8 +87,7 @@ class TestPuppetUtil < Test::Unit::TestCase
end
[:Yay, "Cool"].each do |var|
- assert_equal(inst.hash[var], inst[var],
- "Var %s did not take" % var)
+ assert_equal(inst.hash[var], inst[var], "Var %s did not take" % var)
end
end
@@ -191,31 +189,34 @@ class TestPuppetUtil < Test::Unit::TestCase
end
def test_lang_environ_in_execute
- orig_lang = ENV["LANG"]
- orig_lc_all = ENV["LC_ALL"]
- orig_lc_messages = ENV["LC_MESSAGES"]
- orig_language = ENV["LANGUAGE"]
-
- cleanup do
- ENV["LANG"] = orig_lang
- ENV["LC_ALL"] = orig_lc_all
- ENV["LC_MESSAGES"] = orig_lc_messages
- ENV["LANGUAGE"] = orig_lc_messages
- end
-
- # Mmm, we love gettext(3)
- ENV["LANG"] = "en_US"
- ENV["LC_ALL"] = "en_US"
- ENV["LC_MESSAGES"] = "en_US"
- ENV["LANGUAGE"] = "en_US"
-
- %w{LANG LC_ALL LC_MESSAGES LANGUAGE}.each do |env|
- assert_equal('C',
- Puppet::Util.execute(['ruby', '-e', "print ENV['#{env}']"]),
- "Environment var #{env} wasn't set to 'C'")
-
- assert_equal 'en_US', ENV[env], "Environment var #{env} not set back correctly"
- end
+ orig_lang = ENV["LANG"]
+ orig_lc_all = ENV["LC_ALL"]
+ orig_lc_messages = ENV["LC_MESSAGES"]
+ orig_language = ENV["LANGUAGE"]
+
+ cleanup do
+ ENV["LANG"] = orig_lang
+ ENV["LC_ALL"] = orig_lc_all
+ ENV["LC_MESSAGES"] = orig_lc_messages
+ ENV["LANGUAGE"] = orig_lc_messages
+ end
+
+ # Mmm, we love gettext(3)
+ ENV["LANG"] = "en_US"
+ ENV["LC_ALL"] = "en_US"
+ ENV["LC_MESSAGES"] = "en_US"
+ ENV["LANGUAGE"] = "en_US"
+
+ %w{LANG LC_ALL LC_MESSAGES LANGUAGE}.each do |env|
+
+ assert_equal(
+ 'C',
+ Puppet::Util.execute(['ruby', '-e', "print ENV['#{env}']"]),
+
+ "Environment var #{env} wasn't set to 'C'")
+
+ assert_equal 'en_US', ENV[env], "Environment var #{env} not set back correctly"
+ end
end