summaryrefslogtreecommitdiffstats
path: root/test/ral/providers
diff options
context:
space:
mode:
Diffstat (limited to 'test/ral/providers')
-rwxr-xr-xtest/ral/providers/cron/crontab.rb28
-rwxr-xr-xtest/ral/providers/provider.rb35
2 files changed, 56 insertions, 7 deletions
diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb
index 53bd76c50..900a0478e 100755
--- a/test/ral/providers/cron/crontab.rb
+++ b/test/ral/providers/cron/crontab.rb
@@ -599,5 +599,33 @@ class TestCronParsedProvider < Test::Unit::TestCase
result = target.read
assert_equal("# Puppet Name: test\n* 4 * * * /bin/echo yay\n", result, "Did not write out environment setting")
end
+
+ # Testing #1216
+ def test_strange_lines
+ @provider.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram))
+ text = " 5 \t\t 1,2 * 1 0 /bin/echo funtest"
+
+ records = nil
+ assert_nothing_raised {
+ records = @provider.parse(text)
+ }
+
+ should = {
+ :minute => %w{5},
+ :hour => %w{1 2},
+ :monthday => :absent,
+ :month => %w{1},
+ :weekday => %w{0},
+ :command => "/bin/echo funtest"
+ }
+
+ is = records.shift
+ assert(is, "Did not get record")
+
+ should.each do |p, v|
+ assert_equal(v, is[p], "did not parse %s correctly" % p)
+ end
+ end
+
end
diff --git a/test/ral/providers/provider.rb b/test/ral/providers/provider.rb
index 2196fafce..70f606a37 100755
--- a/test/ral/providers/provider.rb
+++ b/test/ral/providers/provider.rb
@@ -37,12 +37,13 @@ class TestProvider < Test::Unit::TestCase
cleanup { Puppet::Type.rmtype(:provider_test) }
end
- def test_confine
- provider = newprovider
+ def test_confine_defaults_to_suitable
- assert(provider.suitable?,
- "Marked unsuitable with no confines")
+ provider = newprovider
+ assert(provider.suitable?, "Marked unsuitable with no confines")
+ end
+ def test_confine_results
{
{:true => true} => true,
{:true => false} => false,
@@ -54,6 +55,8 @@ class TestProvider < Test::Unit::TestCase
{:exists => echo} => true,
{:exists => "/this/file/does/not/exist"} => false,
}.each do |hash, result|
+ provider = newprovider
+
# First test :true
hash.each do |test, val|
assert_nothing_raised do
@@ -61,19 +64,25 @@ class TestProvider < Test::Unit::TestCase
end
end
- assert_equal(result, provider.suitable?,
- "Failed for %s" % [hash.inspect])
+ assert_equal(result, provider.suitable?, "Failed for %s" % [hash.inspect])
provider.initvars
end
+ end
+
+ def test_multiple_confines_do_not_override
+ provider = newprovider
# Make sure multiple confines don't overwrite each other
provider.confine :true => false
assert(! provider.suitable?)
provider.confine :true => true
assert(! provider.suitable?)
+ end
- provider.initvars
+ def test_one_failed_confine_is_sufficient
+
+ provider = newprovider
# Make sure we test multiple of them, and that a single false wins
provider.confine :true => true, :false => false
@@ -82,6 +91,18 @@ class TestProvider < Test::Unit::TestCase
assert(! provider.suitable?)
end
+ # #1197 - the binary should not be
+ def test_command_checks_for_binaries_each_time
+ provider = newprovider
+
+ provider.commands :testing => "/no/such/path"
+
+ provider.stubs(:binary).returns "/no/such/path"
+
+ provider.command(:testing)
+ assert_equal("/no/such/path", provider.command(:testing), "Did not return correct binary path")
+ end
+
def test_command
{:echo => "echo", :echo_with_path => echo, :missing => "nosuchcommand", :missing_qualified => "/path/to/nosuchcommand"}.each do |name, command|
provider = newprovider