diff options
Diffstat (limited to 'test/ral/type/file.rb')
-rwxr-xr-x | test/ral/type/file.rb | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/test/ral/type/file.rb b/test/ral/type/file.rb index 726dcb72f..06795de7d 100755 --- a/test/ral/type/file.rb +++ b/test/ral/type/file.rb @@ -20,7 +20,7 @@ class TestFile < Test::Unit::TestCase end def mktestfile - tmpfile = tempfile() + tmpfile = tempfile File.open(tmpfile, "w") { |f| f.puts rand(100) } @@tmpfiles.push tmpfile mkfile(:name => tmpfile) @@ -50,7 +50,7 @@ class TestFile < Test::Unit::TestCase end def test_owner - file = mktestfile() + file = mktestfile users = {} count = 0 @@ -82,10 +82,10 @@ class TestFile < Test::Unit::TestCase us[uid] = name users.each { |uid, name| assert_apply(file) - assert_nothing_raised() { + assert_nothing_raised { file[:owner] = name } - assert_nothing_raised() { + assert_nothing_raised { file.retrieve } assert_apply(file) @@ -93,9 +93,9 @@ class TestFile < Test::Unit::TestCase end def test_group - file = mktestfile() + file = mktestfile [%x{groups}.chomp.split(/ /), Process.groups].flatten.each { |group| - assert_nothing_raised() { + assert_nothing_raised { file[:group] = group } assert(file.property(:group)) @@ -111,9 +111,9 @@ class TestFile < Test::Unit::TestCase if Puppet.features.root? def test_createasuser - dir = tmpdir() + dir = tmpdir - user = nonrootuser() + user = nonrootuser path = File.join(tmpdir, "createusertesting") @@tmpfiles << path @@ -136,7 +136,7 @@ class TestFile < Test::Unit::TestCase end def test_nofollowlinks - basedir = tempfile() + basedir = tempfile Dir.mkdir(basedir) file = File.join(basedir, "file") link = File.join(basedir, "link") @@ -145,7 +145,7 @@ class TestFile < Test::Unit::TestCase File.symlink(file, link) # First test 'user' - user = nonrootuser() + user = nonrootuser inituser = File.lstat(link).uid File.lchown(inituser, nil, link) @@ -205,7 +205,7 @@ class TestFile < Test::Unit::TestCase end def test_ownerasroot - file = mktestfile() + file = mktestfile users = {} count = 0 @@ -234,13 +234,13 @@ class TestFile < Test::Unit::TestCase end users.each { |uid, name| - assert_nothing_raised() { + assert_nothing_raised { file[:owner] = name } assert_apply(file) currentvalue = file.retrieve assert(file.insync?(currentvalue)) - assert_nothing_raised() { + assert_nothing_raised { file[:owner] = uid } assert_apply(file) @@ -261,10 +261,10 @@ class TestFile < Test::Unit::TestCase end def test_groupasroot - file = mktestfile() + file = mktestfile [%x{groups}.chomp.split(/ /), Process.groups].flatten.each { |group| next unless Puppet::Util.gid(group) # grr. - assert_nothing_raised() { + assert_nothing_raised { file[:group] = group } assert(file.property(:group)) @@ -272,7 +272,7 @@ class TestFile < Test::Unit::TestCase assert_apply(file) currentvalue = file.retrieve assert(file.insync?(currentvalue)) - assert_nothing_raised() { + assert_nothing_raised { file.delete(:group) } } @@ -280,7 +280,7 @@ class TestFile < Test::Unit::TestCase if Facter.value(:operatingsystem) == "Darwin" def test_sillyowner - file = tempfile() + file = tempfile File.open(file, "w") { |f| f.puts "" } File.chown(-2, nil, file) @@ -304,9 +304,9 @@ class TestFile < Test::Unit::TestCase end def test_create - %w{a b c d}.collect { |name| tempfile() + name.to_s }.each { |path| + %w{a b c d}.collect { |name| tempfile + name.to_s }.each { |path| file =nil - assert_nothing_raised() { + assert_nothing_raised { file = Puppet::Type.type(:file).new( @@ -323,11 +323,11 @@ class TestFile < Test::Unit::TestCase end def test_create_dir - basedir = tempfile() + basedir = tempfile Dir.mkdir(basedir) %w{a b c d}.collect { |name| "#{basedir}/#{name}" }.each { |path| file = nil - assert_nothing_raised() { + assert_nothing_raised { file = Puppet::Type.type(:file).new( @@ -349,13 +349,13 @@ class TestFile < Test::Unit::TestCase # Set it to something else initially File.chmod(0775, file.title) [0644,0755,0777,0641].each { |mode| - assert_nothing_raised() { + assert_nothing_raised { file[:mode] = mode } assert_events([:mode_changed], file) assert_events([], file) - assert_nothing_raised() { + assert_nothing_raised { file.delete(:mode) } } @@ -403,7 +403,7 @@ class TestFile < Test::Unit::TestCase file = Puppet::Type.type(:file).new( - :name => tmpdir(), + :name => tmpdir, :check => :type ) @@ -416,7 +416,7 @@ class TestFile < Test::Unit::TestCase file = Puppet::Type.type(:file).new( - :name => tempfile(), + :name => tempfile, :ensure => "file" ) @@ -430,7 +430,7 @@ class TestFile < Test::Unit::TestCase end def test_path - dir = tempfile() + dir = tempfile path = File.join(dir, "subdir") @@ -467,7 +467,7 @@ class TestFile < Test::Unit::TestCase end def test_autorequire - basedir = tempfile() + basedir = tempfile subfile = File.join(basedir, "subfile") @@ -496,7 +496,7 @@ class TestFile < Test::Unit::TestCase # Unfortunately, I know this fails def disabled_test_recursivemkdir - path = tempfile() + path = tempfile subpath = File.join(path, "this", "is", "a", "dir") file = nil assert_nothing_raised { @@ -520,7 +520,7 @@ class TestFile < Test::Unit::TestCase # Make sure that content updates the checksum on the same run def test_checksumchange_for_content - dest = tempfile() + dest = tempfile File.open(dest, "w") { |f| f.puts "yayness" } file = nil @@ -545,7 +545,7 @@ class TestFile < Test::Unit::TestCase # Make sure that content updates the checksum on the same run def test_checksumchange_for_ensure - dest = tempfile() + dest = tempfile file = nil assert_nothing_raised { @@ -567,7 +567,7 @@ class TestFile < Test::Unit::TestCase end def test_nameandpath - path = tempfile() + path = tempfile file = nil assert_nothing_raised { @@ -593,7 +593,7 @@ class TestFile < Test::Unit::TestCase file = Puppet::Type.type(:file).new( - :path => tempfile(), + :path => tempfile, :group => "fakegroup" ) @@ -603,7 +603,7 @@ class TestFile < Test::Unit::TestCase end def test_modecreation - path = tempfile() + path = tempfile file = Puppet::Type.type(:file).new( @@ -624,7 +624,7 @@ class TestFile < Test::Unit::TestCase # If both 'ensure' and 'content' are used, make sure that all of the other # properties are handled correctly. def test_contentwithmode - path = tempfile() + path = tempfile file = nil assert_nothing_raised { @@ -644,8 +644,8 @@ class TestFile < Test::Unit::TestCase end def test_replacefilewithlink - path = tempfile() - link = tempfile() + path = tempfile + link = tempfile File.open(path, "w") { |f| f.puts "yay" } File.open(link, "w") { |f| f.puts "a file" } @@ -670,7 +670,7 @@ class TestFile < Test::Unit::TestCase end def test_file_with_spaces - dir = tempfile() + dir = tempfile Dir.mkdir(dir) source = File.join(dir, "file spaces") dest = File.join(dir, "another space") @@ -692,8 +692,8 @@ class TestFile < Test::Unit::TestCase # Testing #274. Make sure target can be used without 'ensure'. def test_target_without_ensure - source = tempfile() - dest = tempfile() + source = tempfile + dest = tempfile File.open(source, "w") { |f| f.puts "funtest" } obj = nil @@ -705,7 +705,7 @@ class TestFile < Test::Unit::TestCase end def test_autorequire_owner_and_group - file = tempfile() + file = tempfile comp = nil user = nil group =nil @@ -759,7 +759,7 @@ class TestFile < Test::Unit::TestCase # Testing #364. def test_writing_in_directories_with_no_write_access # Make a directory that our user does not have access to - dir = tempfile() + dir = tempfile Dir.mkdir(dir) # Get a fake user @@ -796,7 +796,7 @@ class TestFile < Test::Unit::TestCase # #366 def test_replace_aliases - file = Puppet::Type.newfile :path => tempfile() + file = Puppet::Type.newfile :path => tempfile file[:replace] = :yes assert_equal(:true, file[:replace], ":replace did not alias :true to :yes") file[:replace] = :no @@ -804,7 +804,7 @@ class TestFile < Test::Unit::TestCase end def test_pathbuilder - dir = tempfile() + dir = tempfile Dir.mkdir(dir) file = File.join(dir, "file") File.open(file, "w") { |f| f.puts "" } @@ -822,7 +822,7 @@ class TestFile < Test::Unit::TestCase # Testing #403 def test_removal_with_content_set - path = tempfile() + path = tempfile File.open(path, "w") { |f| f.puts "yay" } file = Puppet::Type.newfile(:name => path, :ensure => :absent, :content => "foo", :backup => false) @@ -832,9 +832,9 @@ class TestFile < Test::Unit::TestCase # Testing #438 def test_creating_properties_conflict - file = tempfile() - first = tempfile() - second = tempfile() + file = tempfile + first = tempfile + second = tempfile params = [:content, :source, :target] params.each do |param| assert_nothing_raised("#{param} conflicted with ensure") do @@ -852,14 +852,14 @@ class TestFile < Test::Unit::TestCase # Testing #508 if Process.uid == 0 def test_files_replace_with_right_attrs - source = tempfile() + source = tempfile File.open(source, "w") { |f| f.puts "some text" } File.chmod(0755, source) user = nonrootuser group = nonrootgroup - path = tempfile() + path = tempfile good = {:uid => user.uid, :gid => group.gid, :mode => 0640} run = Proc.new do |obj, msg| |