3 require File.dirname(__FILE__) + '/../lib/puppettest'
8 class TestOverrides < Test::Unit::TestCase
10 def mksubdirs(basedir, level)
14 (level + 1).times { |index|
16 path = File.join(dir, "file")
17 File.open(path, "w") { |f| f.puts "yayness" }
18 dir = File.join(dir, index.to_s)
22 def test_simpleoverride
23 basedir = File.join(tmpdir(), "overridetesting")
27 basefile = File.join(basedir, "file")
28 assert_nothing_raised("Could not create base obj") {
29 baseobj = Puppet.type(:file).create(
38 subdir = File.join(basedir, "0")
39 subfile = File.join(subdir, "file")
40 assert_nothing_raised("Could not create sub obj") {
41 subobj = Puppet.type(:file).create(
49 assert_apply(baseobj, subobj)
51 assert(File.stat(basefile).mode & 007777 == 0755)
52 assert(File.stat(subfile).mode & 007777 == 0644)
56 basedir = File.join(tmpdir(), "deepoverridetesting")
57 mksubdirs(basedir, 10)
60 assert_nothing_raised("Could not create base obj") {
61 baseobj = Puppet.type(:file).create(
74 subdir = File.join(subdir, index.to_s)
75 path = File.join(subdir, "file")
84 assert_nothing_raised("Could not create sub obj") {
85 children << Puppet.type(:file).create(
93 config = mk_catalog(baseobj, *children)
95 assert_nothing_raised("Could not eval component") {
99 files.each { |path, mode|
100 assert(FileTest.exists?(path), "File %s does not exist" % path)
101 curmode = File.stat(path).mode & 007777
102 assert(curmode == mode,
103 "File %s was incorrect mode %o instead of %o" % [path, curmode, mode])