summaryrefslogtreecommitdiffstats
path: root/test/language/snippets.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/language/snippets.rb')
-rwxr-xr-xtest/language/snippets.rb36
1 files changed, 13 insertions, 23 deletions
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index 2a4ba0220..01d77c265 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -14,7 +14,8 @@ class TestSnippets < Test::Unit::TestCase
def setup
super
- @file = Puppet::Type.type(:file)
+ Facter.stubs(:to_hash).returns({})
+ Facter.stubs(:value).returns("whatever")
end
def self.snippetdir
@@ -22,14 +23,14 @@ class TestSnippets < Test::Unit::TestCase
end
def assert_file(path, msg = nil)
- unless file = @file[path]
+ unless file = @catalog.resource(:file, path)
msg ||= "Could not find file %s" % path
raise msg
end
end
def assert_mode_equal(mode, path)
- unless file = @file[path]
+ unless file = @catalog.resource(:file, path)
raise "Could not find file %s" % path
end
@@ -211,8 +212,8 @@ class TestSnippets < Test::Unit::TestCase
path1 = "/tmp/argumenttest1"
path2 = "/tmp/argumenttest2"
- file1 = @file[path1]
- file2 = @file[path2]
+ file1 = @catalog.resource(:file, path1)
+ file2 = @catalog.resource(:file, path2)
assert_file(path1)
assert_mode_equal(0755, path1)
@@ -231,7 +232,7 @@ class TestSnippets < Test::Unit::TestCase
}
paths.each { |path|
- file = @file[path]
+ file = @catalog.resource(:file, path)
assert(file, "File %s is missing" % path)
assert_mode_equal(0755, path)
}
@@ -241,7 +242,7 @@ class TestSnippets < Test::Unit::TestCase
paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l }
paths.each { |path|
- file = @file[path]
+ file = @catalog.resource(:file, path)
assert_file(path)
assert_mode_equal(0755, path)
}
@@ -262,7 +263,7 @@ class TestSnippets < Test::Unit::TestCase
dir = "/tmp/testdirtest"
assert_file(file)
assert_file(dir)
- assert_equal(:directory, @file[dir].should(:ensure), "Directory is not set to be a directory")
+ assert_equal(:directory, @catalog.resource(:file, dir).should(:ensure), "Directory is not set to be a directory")
end
def snippet_scopetest
@@ -349,7 +350,7 @@ class TestSnippets < Test::Unit::TestCase
}.each { |count, str|
path = "/tmp/singlequote%s" % count
assert_file(path)
- assert_equal(str, @file[path].should(:content))
+ assert_equal(str, @catalog.resource(:file, path).should(:content))
}
end
@@ -387,21 +388,20 @@ class TestSnippets < Test::Unit::TestCase
end
def snippet_emptyexec
- assert(Puppet::Type.type(:exec)["touch /tmp/emptyexectest"],
- "Did not create exec")
+ assert(@catalog.resource(:exec, "touch /tmp/emptyexectest"), "Did not create exec")
end
def snippet_multisubs
path = "/tmp/multisubtest"
assert_file(path)
- file = @file[path]
+ file = @catalog.resource(:file, path)
assert_equal("sub2", file.should(:content), "sub2 did not override content")
assert_mode_equal(0755, path)
end
def snippet_collection
assert_file("/tmp/colltest1")
- assert_nil(@file["/tmp/colltest2"], "Incorrectly collected file")
+ assert_nil(@catalog.resource(:file, "/tmp/colltest2"), "Incorrectly collected file")
end
def snippet_virtualresources
@@ -469,16 +469,6 @@ class TestSnippets < Test::Unit::TestCase
catalog = catalog.to_ral
}
- Puppet::Type.eachtype { |type|
- type.each { |obj|
- # don't worry about this for now
- #unless obj.name == "puppet[top]" or
- # obj.is_a?(Puppet.type(:schedule))
- # assert(obj.parent, "%s has no parent" % obj.name)
- #end
- assert(obj.name)
- }
- }
@catalog = catalog
assert_nothing_raised {
self.send(mname)