summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-01-15 15:13:28 -0600
committerJames Turnbull <james@lovedthanlost.net>2009-02-13 14:16:35 +1100
commit4e89156b21b287b683c27a4cd691856c4e378a62 (patch)
treee4b1b3e607682d32d6eae5fd3b5b6c08ac3e1130 /test
parentcc4d6586d420f4beea1eeef85cfe7a28f8e493ac (diff)
downloadpuppet-4e89156b21b287b683c27a4cd691856c4e378a62.tar.gz
puppet-4e89156b21b287b683c27a4cd691856c4e378a62.tar.xz
puppet-4e89156b21b287b683c27a4cd691856c4e378a62.zip
Migrated FileType tests to spec, and fleshed them out a bit.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/util/filetype.rb91
1 files changed, 0 insertions, 91 deletions
diff --git a/test/util/filetype.rb b/test/util/filetype.rb
index 6c7ede07b..5b01a8bb4 100755
--- a/test/util/filetype.rb
+++ b/test/util/filetype.rb
@@ -8,97 +8,6 @@ require 'mocha'
class TestFileType < Test::Unit::TestCase
include PuppetTest
-
- def test_flat
- obj = nil
- path = tempfile()
- type = nil
-
- assert_nothing_raised {
- type = Puppet::Util::FileType.filetype(:flat)
- }
-
- assert(type, "Could not retrieve flat filetype")
-
- assert_nothing_raised {
- obj = type.new(path)
- }
-
- text = "This is some text\n"
-
- newtext = nil
- assert_nothing_raised {
- newtext = obj.read
- }
-
- # The base class doesn't allow a return of nil
- assert_equal("", newtext, "Somehow got some text")
-
- assert_nothing_raised {
- obj.write(text)
- }
- assert_nothing_raised {
- newtext = obj.read
- }
-
- assert_equal(text, newtext, "Text was changed somehow")
-
- File.open(path, "w") { |f| f.puts "someyayness" }
-
- text = File.read(path)
- assert_nothing_raised {
- newtext = obj.read
- }
-
- assert_equal(text, newtext, "Text was changed somehow")
- end
-
- # Make sure that modified files are backed up before they're changed.
- def test_backup_is_called
- path = tempfile
- File.open(path, "w") { |f| f.print 'yay' }
-
- obj = Puppet::Util::FileType.filetype(:flat).new(path)
-
- obj.expects(:backup)
-
- obj.write("something")
-
- assert_equal("something", File.read(path), "File did not get changed")
- end
-
- def test_backup
- path = tempfile
- type = Puppet::Type.type(:filebucket)
-
- obj = Puppet::Util::FileType.filetype(:flat).new(path)
-
- # First try it when the file does not yet exist.
- assert_nothing_raised("Could not call backup when file does not exist") do
- obj.backup
- end
-
- # Then create the file
- File.open(path, "w") { |f| f.print 'one' }
-
- # Then try it with no filebucket objects
- assert_nothing_raised("Could not call backup with no buckets") do
- obj.backup
- end
- puppet = type["puppet"]
- assert(puppet, "Did not create default filebucket")
-
- assert_equal("one", puppet.bucket.getfile(Digest::MD5.hexdigest(File.read(path))), "Could not get file from backup")
-
- # Try it again when the default already exists
- File.open(path, "w") { |f| f.print 'two' }
- assert_nothing_raised("Could not call backup with no buckets") do
- obj.backup
- end
-
- assert_equal("two", puppet.bucket.getfile(Digest::MD5.hexdigest(File.read(path))), "Could not get file from backup")
- end
-
if Facter["operatingsystem"].value == "Darwin"
def test_ninfotoarray
obj = nil