summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-02 00:32:52 -0500
committerLuke Kanies <luke@madstop.com>2008-07-02 00:32:52 -0500
commit8e4312ed249d83ece754b80e993fa0d86bd36d46 (patch)
tree8b6044079dbb05a1f84a09a2f8e99cf1b87a3e9e /test
parent49016bb29312bfeb6f41ce420159e6ffc477eebe (diff)
parentd3a81255245eec19ac21902ae3b877e00e620628 (diff)
downloadpuppet-8e4312ed249d83ece754b80e993fa0d86bd36d46.tar.gz
puppet-8e4312ed249d83ece754b80e993fa0d86bd36d46.tar.xz
puppet-8e4312ed249d83ece754b80e993fa0d86bd36d46.zip
Merge branch '0.24.x'
Conflicts: CHANGELOG spec/unit/node/catalog.rb spec/unit/type/package.rb spec/unit/type/schedule.rb spec/unit/type/service.rb spec/unit/util/settings.rb
Diffstat (limited to 'test')
-rwxr-xr-xtest/network/client/master.rb16
-rwxr-xr-xtest/ral/providers/cron/crontab.rb9
-rwxr-xr-xtest/util/loadedfile.rb121
3 files changed, 15 insertions, 131 deletions
diff --git a/test/network/client/master.rb b/test/network/client/master.rb
index 5399fca13..24c7b6374 100755
--- a/test/network/client/master.rb
+++ b/test/network/client/master.rb
@@ -177,10 +177,12 @@ end
assert(File.exists?(destfile), "Did not get fact")
- assert_equal(hostname, Facter.value(:hostname),
+ facts = Puppet::Network::Client.master.facts
+
+ assert_equal(hostname, facts["hostname"],
"Lost value to hostname")
- assert_equal("yayness", Facter.value(:myfact),
+ assert_equal("yayness", facts["myfact"],
"Did not get correct fact value")
# Now modify the file and make sure the type is replaced
@@ -194,20 +196,22 @@ end
assert_nothing_raised {
Puppet::Network::Client.master.getfacts
}
+ facts = Puppet::Network::Client.master.facts
- assert_equal("funtest", Facter.value(:myfact),
+ assert_equal("funtest", facts["myfact"],
"Did not reload fact")
- assert_equal(hostname, Facter.value(:hostname),
+ assert_equal(hostname, facts["hostname"],
"Lost value to hostname")
# Now run it again and make sure the fact still loads
assert_nothing_raised {
Puppet::Network::Client.master.getfacts
}
+ facts = Puppet::Network::Client.master.facts
- assert_equal("funtest", Facter.value(:myfact),
+ assert_equal("funtest", facts["myfact"],
"Did not reload fact")
- assert_equal(hostname, Facter.value(:hostname),
+ assert_equal(hostname, facts["hostname"],
"Lost value to hostname")
end
diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb
index 900a0478e..d9f460258 100755
--- a/test/ral/providers/cron/crontab.rb
+++ b/test/ral/providers/cron/crontab.rb
@@ -530,8 +530,6 @@ class TestCronParsedProvider < Test::Unit::TestCase
@provider.initvars
str += "\n"
target.write(str)
- assert_equal(str, target.read,
- "Did not write correctly")
assert_nothing_raised("Could not prefetch with %s" % str.inspect) do
@provider.prefetch
end
@@ -551,6 +549,11 @@ class TestCronParsedProvider < Test::Unit::TestCase
end
end
+ # #707
+ def test_write_freebsd_special
+ assert_equal(@provider.to_line(:record_type => :crontab, :ensure => :present, :special => "reboot", :command => "/bin/echo something"), "@reboot /bin/echo something")
+ end
+
def test_prefetch
cron = @type.create :command => "/bin/echo yay", :name => "test", :hour => 4
@@ -626,6 +629,4 @@ class TestCronParsedProvider < Test::Unit::TestCase
assert_equal(v, is[p], "did not parse %s correctly" % p)
end
end
-
end
-
diff --git a/test/util/loadedfile.rb b/test/util/loadedfile.rb
deleted file mode 100755
index fb640466a..000000000
--- a/test/util/loadedfile.rb
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../lib/puppettest'
-
-require 'puppet'
-require 'puppet/util/loadedfile'
-require 'puppettest'
-
-class TestLoadedFile < Test::Unit::TestCase
- include PuppetTest
- def test_file
- Puppet[:filetimeout] = 0
- file = nil
- path = tempfile()
- File.open(path, "w") { |f| f.puts "yayness" }
- assert_nothing_raised {
- file = Puppet::Util::LoadedFile.new(path)
- }
-
- assert(!file.changed?, "File incorrectly returned changed")
-
- File.open(path, "w") { |f| f.puts "booness" }
- #file.tstamp = File.stat(path).ctime - 5
- new = File.stat(path).ctime - 5
- file.tstamp = new
-
- assert(file.changed?, "File did not catch change")
- end
-
- def test_timeout
- Puppet[:filetimeout] = 50
- path = tempfile()
-
- File.open(path, "w") { |f| f.puts "yay" }
- file = nil
- assert_nothing_raised {
- file = Puppet::Util::LoadedFile.new(path)
- }
-
- assert_nothing_raised {
- assert(!file.changed?,
- "File thought it changed immediately")
- }
-
- sleep 1
- File.open(path, "w") { |f| f.puts "yay" }
- #file.tstamp = File.stat(path).ctime - 5
-
- assert(!file.changed?,
- "File was marked as changed too soon")
-
- Puppet[:filetimeout] = 0
- assert(file.changed?,
- "File was not marked as changed soon enough")
- end
-
- def test_stamp
- file = tempfile()
- File.open(file, "w") { |f| f.puts "" }
- obj = nil
- assert_nothing_raised {
- obj = Puppet::Util::LoadedFile.new(file)
- }
-
- # Make sure we don't refresh
- Puppet[:filetimeout] = 50
-
- stamp = File.stat(file).ctime
-
- assert_equal(stamp, obj.stamp)
-
- sleep 1
- # Now change the file, and make sure the stamp doesn't update yet
- File.open(file, "w") { |f| f.puts "" }
- assert_equal(stamp, obj.stamp,
- "File prematurely refreshed")
-
- Puppet[:filetimeout] = 0
- assert_equal(File.stat(file).ctime, obj.stamp,
- "File did not refresh")
- end
-
- # Testing #394.
- def test_changed_missing_file
- file = tempfile()
- File.open(file, "w") { |f| f.puts "" }
- obj = nil
- assert_nothing_raised {
- obj = Puppet::Util::LoadedFile.new(file)
- }
- Puppet[:filetimeout] = -10
-
- assert_nothing_raised {
- obj.changed?
- }
-
- # Now remove the file
- File.unlink(file)
-
- assert_nothing_raised("removed file threw an error") {
- assert(obj.changed?, "File was not considered changed when missing")
- }
- end
-
- # Make sure negative values always result in change notifications.
- def test_negative_always_changes
- file = tempfile()
- File.open(file, "w") { |f| f.puts "" }
- obj = nil
- assert_nothing_raised {
- obj = Puppet::Util::LoadedFile.new(file)
- }
-
- assert(! obj.changed?, "file with no change considered changed")
- # Now set a negative value
- Puppet[:filetimeout] = -1
-
- assert(obj.changed?, "negative file timeout did not disable checking")
- end
-end
-