summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-01-09 13:03:15 -0800
committerLuke Kanies <luke@madstop.com>2008-01-09 13:03:15 -0800
commit5bef4a55b3489a6404ee34b900621af8b784749a (patch)
tree82a03e2434597160c8a52125f2c6fd948a942291 /test
parent3cc3e0f5b21deee4fbdbcbae18fba47c7a0cbb1e (diff)
downloadpuppet-5bef4a55b3489a6404ee34b900621af8b784749a.tar.gz
puppet-5bef4a55b3489a6404ee34b900621af8b784749a.tar.xz
puppet-5bef4a55b3489a6404ee34b900621af8b784749a.zip
Another round of fixes toward making global resources work.
The only remaining failures are more complicated ones (which I'll need to not be on a plane to debug, for battery reasons) or those related to the broken directory_service providers.
Diffstat (limited to 'test')
-rwxr-xr-xtest/language/snippets.rb36
-rwxr-xr-xtest/lib/puppettest.rb1
-rwxr-xr-xtest/other/relationships.rb7
-rwxr-xr-xtest/other/transactions.rb32
-rwxr-xr-xtest/ral/manager/instances.rb16
-rwxr-xr-xtest/ral/manager/type.rb161
-rwxr-xr-xtest/ral/types/sshkey.rb39
-rwxr-xr-xtest/ral/types/user.rb1
8 files changed, 81 insertions, 212 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)
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 76ae96e02..68add6dd5 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -278,7 +278,6 @@ module PuppetTest
}
@@tmppids.clear
- Puppet::Type.allclear
Puppet::Util::Storage.clear
Puppet.clear
Puppet.settings.clear
diff --git a/test/other/relationships.rb b/test/other/relationships.rb
index dd51e3165..88d35ce1f 100755
--- a/test/other/relationships.rb
+++ b/test/other/relationships.rb
@@ -81,6 +81,9 @@ class TestRelationships < Test::Unit::TestCase
)
end
+ catalog = mk_catalog(*files)
+ catalog.add_resource(*execs)
+
# Add our first relationship
if out[param]
files[0][param] = execs[0]
@@ -177,8 +180,8 @@ class TestRelationships < Test::Unit::TestCase
# Now make sure that these relationships are added to the
# relationship graph
- config.apply do |trans|
- assert(config.relationship_graph.edge?(file, exec), "autorequire edge was not created")
+ catalog.apply do |trans|
+ assert(catalog.relationship_graph.edge?(file, exec), "autorequire edge was not created")
end
end
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 79971a28b..649a3cd32 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -6,10 +6,12 @@ require 'puppet'
require 'puppettest'
require 'mocha'
require 'puppettest/support/resources'
+require 'puppettest/support/utils'
class TestTransactions < Test::Unit::TestCase
include PuppetTest::FileTesting
include PuppetTest::Support::Resources
+ include PuppetTest::Support::Utils
class Fakeprop <Puppet::Property
attr_accessor :path, :is, :should, :name
def should_to_s(value)
@@ -596,15 +598,15 @@ class TestTransactions < Test::Unit::TestCase
yay = Puppet::Type.newgenerator :title => "yay"
rah = Puppet::Type.newgenerator :title => "rah"
- config = mk_catalog(yay, rah)
- trans = Puppet::Transaction.new(config)
+ catalog = mk_catalog(yay, rah)
+ trans = Puppet::Transaction.new(catalog)
assert_nothing_raised do
trans.generate
end
%w{ya ra y r}.each do |name|
- assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]),
+ assert(catalog.resource(:generator, name),
"Generated %s was not a vertex" % name)
assert($finished.include?(name), "%s was not finished" % name)
end
@@ -615,10 +617,8 @@ class TestTransactions < Test::Unit::TestCase
end
%w{ya ra y r}.each do |name|
- assert(!trans.catalog.vertex?(Puppet::Type.type(:generator)[name]),
+ assert(! catalog.resource(:generator, name),
"Generated vertex %s was not removed from graph" % name)
- assert_nil(Puppet::Type.type(:generator)[name],
- "Generated vertex %s was not removed from class" % name)
end
end
@@ -635,8 +635,8 @@ class TestTransactions < Test::Unit::TestCase
yay = Puppet::Type.newgenerator :title => "yay"
rah = Puppet::Type.newgenerator :title => "rah", :subscribe => yay
- config = mk_catalog(yay, rah)
- trans = Puppet::Transaction.new(config)
+ catalog = mk_catalog(yay, rah)
+ trans = Puppet::Transaction.new(catalog)
trans.prepare
@@ -645,7 +645,7 @@ class TestTransactions < Test::Unit::TestCase
assert_nothing_raised("failed to apply yay") do
trans.eval_resource(yay)
end
- ya = type["ya"]
+ ya = catalog.resource(type.name, "ya")
assert(ya, "Did not generate ya")
assert(trans.relationship_graph.vertex?(ya),
"Did not add ya to rel_graph")
@@ -658,11 +658,11 @@ class TestTransactions < Test::Unit::TestCase
# Now make sure it in turn eval_generates appropriately
assert_nothing_raised("failed to apply yay") do
- trans.eval_resource(type["ya"])
+ trans.eval_resource(catalog.resource(type.name, "ya"))
end
%w{y}.each do |name|
- res = type[name]
+ res = catalog.resource(type.name, "ya")
assert(res, "Did not generate %s" % name)
assert(trans.relationship_graph.vertex?(res),
"Did not add %s to rel_graph" % name)
@@ -670,7 +670,7 @@ class TestTransactions < Test::Unit::TestCase
end
assert_nothing_raised("failed to eval_generate with nil response") do
- trans.eval_resource(type["y"])
+ trans.eval_resource(catalog.resource(type.name, "y"))
end
assert(trans.relationship_graph.edge?(yay, ya), "no edge was created for ya => yay")
@@ -678,7 +678,7 @@ class TestTransactions < Test::Unit::TestCase
trans.eval_resource(rah)
end
- ra = type["ra"]
+ ra = catalog.resource(type.name, "ra")
assert(ra, "Did not generate ra")
assert(trans.relationship_graph.vertex?(ra),
"Did not add ra to rel_graph" % name)
@@ -697,14 +697,12 @@ class TestTransactions < Test::Unit::TestCase
end
%w{ya ra y r}.each do |name|
- assert(!trans.relationship_graph.vertex?(type[name]),
+ assert(!trans.relationship_graph.vertex?(catalog.resource(type.name, name)),
"Generated vertex %s was not removed from graph" % name)
- assert_nil(type[name],
- "Generated vertex %s was not removed from class" % name)
end
# Now, start over and make sure that everything gets evaluated.
- trans = Puppet::Transaction.new(config)
+ trans = Puppet::Transaction.new(catalog)
$evaluated.clear
assert_nothing_raised do
trans.evaluate
diff --git a/test/ral/manager/instances.rb b/test/ral/manager/instances.rb
index a50ecb213..5305b3ff3 100755
--- a/test/ral/manager/instances.rb
+++ b/test/ral/manager/instances.rb
@@ -89,21 +89,5 @@ class TestTypeInstances < Test::Unit::TestCase
# Now make sure the resources have an 'ensure' property to go with the value in the provider
assert(resources[:one].send(:instance_variable_get, "@parameters").include?(:ensure), "Did not create ensure property")
end
-
- # Make sure resources are entirely deleted.
- def test_delete
- aliases = %w{one}
- catalog = mk_catalog
- obj = @type.create(:name => "testing", :alias => "two", :catalog => catalog)
- aliases << "two"
-
- @type.alias("two", obj)
-
- obj.remove
- assert_nil(@type["testing"], "Object was not removed from objects hash")
- assert_nil(@type["one"], "Object's alias was not removed")
- assert_nil(@type["two"], "Object's second alias was not removed")
-
- end
end
diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb
index 6a044687e..bb13a7b78 100755
--- a/test/ral/manager/type.rb
+++ b/test/ral/manager/type.rb
@@ -65,7 +65,6 @@ class TestType < Test::Unit::TestCase
assert_nothing_raised() {
file.evaluate
}
- Puppet.type(:file).clear
assert_nothing_raised() {
system("rm -f %s" % path)
file = Puppet.type(:file).create(
@@ -110,47 +109,7 @@ class TestType < Test::Unit::TestCase
assert_equal("testing", group.name, "Could not retrieve name")
end
- # Verify that values get merged correctly
- def test_mergepropertyvalues
- file = tempfile()
-
- # Create the first version
- assert_nothing_raised {
- Puppet.type(:file).create(
- :path => file,
- :owner => ["root", "bin"]
- )
- }
-
- # Make sure no other statements are allowed
- assert_raise(Puppet::Error) {
- Puppet.type(:file).create(
- :path => file,
- :group => "root"
- )
- }
- end
-
- def test_aliases_to_self_are_not_failures
- resource = Puppet.type(:file).create(
- :name => "/path/to/some/missing/file",
- :ensure => "file"
- )
- resource.stubs(:path).returns("")
-
- catalog = stub 'catalog'
- catalog.expects(:resource).with(:file, "/path/to/some/missing/file").returns(resource)
- resource.catalog = catalog
-
- # Verify our adding ourselves as an alias isn't an error.
- assert_nothing_raised("Could not add alias") {
- resource[:alias] = "/path/to/some/missing/file"
- }
-
- assert_equal(resource.object_id, Puppet.type(:file)["/path/to/some/missing/file"].object_id, "Could not retrieve alias to self")
- end
-
- def test_aliases_are_added_to_class_and_catalog
+ def test_aliases_are_added_to_catalog
resource = Puppet.type(:file).create(
:name => "/path/to/some/missing/file",
:ensure => "file"
@@ -165,8 +124,6 @@ class TestType < Test::Unit::TestCase
assert_nothing_raised("Could not add alias") {
resource[:alias] = "funtest"
}
-
- assert_equal(resource.object_id, Puppet.type(:file)["funtest"].object_id, "Could not retrieve alias")
end
def test_aliasing_fails_without_a_catalog
@@ -182,7 +139,7 @@ class TestType < Test::Unit::TestCase
def test_catalogs_are_set_during_initialization_if_present_on_the_transobject
trans = Puppet::TransObject.new("/path/to/some/file", :file)
- trans.catalog = :my_config
+ trans.catalog = stub 'catalog', :resource => nil
resource = trans.to_type
assert_equal(resource.catalog, trans.catalog, "Did not set catalog on initialization")
end
@@ -217,37 +174,6 @@ class TestType < Test::Unit::TestCase
assert(twoobj.requires?(oneobj), "Requirement was not created")
end
- # Verify that names are aliases, not equivalents
- def test_nameasalias
- file = nil
- # Create the parent dir, so we make sure autorequiring the parent dir works
- parentdir = tempfile()
- dir = Puppet.type(:file).create(
- :name => parentdir,
- :ensure => "directory"
- )
- assert_apply(dir)
- path = File.join(parentdir, "subdir")
- name = "a test file"
- transport = Puppet::TransObject.new(name, "file")
- transport[:path] = path
- transport[:ensure] = "file"
- assert_nothing_raised {
- file = transport.to_type
- }
-
- assert_equal(path, file[:path])
- assert_equal(name, file.title)
-
- assert_nothing_raised {
- file.retrieve
- }
-
- assert_apply(file)
-
- assert(Puppet.type(:file)[name], "Could not look up object by name")
- end
-
def test_ensuredefault
user = nil
assert_nothing_raised {
@@ -434,7 +360,6 @@ class TestType < Test::Unit::TestCase
assert_equal(path, file[:name], "Did not get correct name")
file = nil
- Puppet::Type.type(:file).clear
# Now make sure we can specify both and still get the right answers
assert_nothing_raised do
@@ -475,7 +400,6 @@ class TestType < Test::Unit::TestCase
# Now try it using the class method on Type
oldid = obj.object_id
obj = nil
- Puppet::Type.type(:file).clear
assert_nothing_raised {
obj = Puppet::Type.create(trans)
@@ -487,7 +411,6 @@ class TestType < Test::Unit::TestCase
# Now try the same things with hashes instead of a transobject
oldid = obj.object_id
obj = nil
- Puppet::Type.type(:file).clear
hash = {
:type => :file,
:title => "Myfile",
@@ -510,7 +433,6 @@ class TestType < Test::Unit::TestCase
# Now try it using the class method on Type
oldid = obj.object_id
obj = nil
- Puppet::Type.type(:file).clear
assert_nothing_raised {
obj = Puppet::Type.create(hash)
@@ -533,25 +455,6 @@ class TestType < Test::Unit::TestCase
end
end
- def test_title_and_name
- obj = nil
- path = tempfile()
- fileobj = Puppet::Type.type(:file)
-
- assert_nothing_raised do
- obj = fileobj.create(
- :title => "myfile",
- :path => path
- )
- end
-
- assert_equal(obj, fileobj["myfile"],
- "Could not retrieve obj by title")
-
- assert_equal(obj, fileobj[path],
- "Could not retrieve obj by name")
- end
-
# Make sure default providers behave correctly
def test_defaultproviders
# Make a fake type
@@ -577,6 +480,7 @@ class TestType < Test::Unit::TestCase
# Make sure that we can have multiple isomorphic objects with the same name,
# but not with non-isomorphic objects.
def test_isomorphic_names
+ catalog = mk_catalog
# First do execs, since they're not isomorphic.
echo = Puppet::Util.binary "echo"
exec1 = exec2 = nil
@@ -586,37 +490,31 @@ class TestType < Test::Unit::TestCase
:command => "#{echo} funtest"
)
end
+ catalog.add_resource(exec1)
assert_nothing_raised do
exec2 = Puppet::Type.type(:exec).create(
:title => "exec2",
:command => "#{echo} funtest"
)
end
-
- assert_apply(exec1, exec2)
+ catalog.add_resource(exec2)
# Now do files, since they are. This should fail.
file1 = file2 = nil
path = tempfile()
- assert_nothing_raised do
- file1 = Puppet::Type.type(:file).create(
- :title => "file1",
- :path => path,
- :content => "yayness"
- )
- end
-
- # This will fail, but earlier systems will catch it.
- assert_raise(Puppet::Error) do
- file2 = Puppet::Type.type(:file).create(
- :title => "file2",
- :path => path,
- :content => "rahness"
- )
- end
+ file1 = Puppet::Type.type(:file).create(
+ :title => "file1",
+ :path => path,
+ :content => "yayness"
+ )
+ catalog.add_resource(file1)
- assert(file1, "Did not create first file")
- assert_nil(file2, "Incorrectly created second file")
+ file2 = Puppet::Type.type(:file).create(
+ :title => "file2",
+ :path => path,
+ :content => "rahness"
+ )
+ assert_raise(ArgumentError) { catalog.add_resource(file2) }
end
def test_tags
@@ -654,20 +552,6 @@ class TestType < Test::Unit::TestCase
end
end
- # Make sure that classes behave like hashes.
- def test_class_hash_behaviour
- path = tempfile()
-
- filetype = Puppet::Type.type(:file)
- one = Puppet::Type.newfile :path => path
-
- assert_equal(one, filetype[path], "Did not get file back")
-
- assert_raise(Puppet::Error) do
- filetype[path] = one
- end
- end
-
def test_ref
path = tempfile()
Puppet::Type.type(:exec) # uggh, the methods need to load the types
@@ -701,7 +585,7 @@ class TestType < Test::Unit::TestCase
type = Puppet::Type.type(:exec)
mk = Proc.new do |i, hash|
hash[:title] = "exec%s" % i
- hash[:command] = "/bin/echo"
+ hash[:command] = "/bin/echo %s" % i
if parent = hash[:parent]
hash.delete(:parent)
end
@@ -769,7 +653,8 @@ class TestType < Test::Unit::TestCase
# Partially test #704, but also cover the rest of the schedule management bases.
def test_schedule
- Puppet::Type.type(:schedule).create(:name => "maint")
+ schedule = Puppet::Type.type(:schedule).create(:name => "maint")
+ catalog = mk_catalog(schedule)
{"maint" => true, nil => false, :fail => :fail}.each do |name, should|
args = {:name => tempfile, :ensure => :file}
@@ -777,21 +662,27 @@ class TestType < Test::Unit::TestCase
args[:schedule] = name
end
resource = Puppet::Type.type(:file).create(args)
+ catalog.add_resource(resource)
if should == :fail
assert_raise(Puppet::Error, "Did not fail on missing schedule") do
resource.schedule
end
+ elsif should == false
+ assert_nil(resource.schedule, "Set the schedule tho it is set to nil")
else
sched = nil
assert_nothing_raised("Failed when schedule was %s" % sched) do
sched = resource.schedule
end
+ assert(sched, "Did not find schedule %s" % sched.inspect)
+
if should
assert_equal(name, sched.name, "did not get correct schedule back")
end
end
+ catalog.remove_resource(resource)
end
end
diff --git a/test/ral/types/sshkey.rb b/test/ral/types/sshkey.rb
index b9aed20e8..c68e4a271 100755
--- a/test/ral/types/sshkey.rb
+++ b/test/ral/types/sshkey.rb
@@ -49,26 +49,27 @@ class TestSSHKey < Test::Unit::TestCase
@catalog ||= mk_catalog
- assert_nothing_raised {
- key = @sshkeytype.create(
- :name => "host%s.madstop.com" % @kcount,
- :key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount,
- :type => "ssh-dss",
- :alias => ["192.168.0.%s" % @kcount],
- :catalog => @catalog
- )
- }
+ key = @sshkeytype.create(
+ :name => "host%s.madstop.com" % @kcount,
+ :key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount,
+ :type => "ssh-dss",
+ :alias => ["192.168.0.%s" % @kcount],
+ :catalog => @catalog
+ )
+
+ @catalog.add_resource(key)
return key
end
def test_instances
+ list = nil
assert_nothing_raised {
- Puppet.type(:sshkey).instances
+ list = Puppet.type(:sshkey).instances
}
count = 0
- @sshkeytype.each do |h|
+ list.each do |h|
count += 1
end
@@ -90,7 +91,6 @@ class TestSSHKey < Test::Unit::TestCase
# Now create a new key object
name = key.name
key = nil
- @sshkeytype.clear
key = @sshkeytype.create :name => name, :target => file, :provider => :parsed
key.retrieve
@@ -109,11 +109,10 @@ class TestSSHKey < Test::Unit::TestCase
aliases = %w{madstop kirby yayness}
key[:alias] = aliases
- params = key.instance_variable_get("@parameters")
assert_events([:sshkey_changed], key)
aliases.each do |name|
- assert_equal(key, key.class[name],
+ assert_equal(key, @catalog.resource(:sshkey, name),
"alias was not set")
end
end
@@ -136,7 +135,9 @@ class TestSSHKey < Test::Unit::TestCase
key[:alias] = "testing"
}
- same = key.class["testing"]
+ key.finish
+
+ same = @catalog.resource(:sshkey, "testing")
assert(same, "Could not retrieve by alias")
end
@@ -170,7 +171,10 @@ class TestSSHKey < Test::Unit::TestCase
}
assert_apply(*keys)
keys.clear
- Puppet.type(:sshkey).clear
+
+ @catalog.clear(true)
+ @catalog = nil
+
newkey = mkkey()
#newkey[:ensure] = :present
names << newkey.name
@@ -184,8 +188,7 @@ class TestSSHKey < Test::Unit::TestCase
# And verify that we have data for everything
names.each { |name|
- key = Puppet.type(:sshkey)[name] ||
- Puppet.type(:sshkey).create(:name => name)
+ key = @catalog.resource(:sshkey, name)
assert(key, "Could not retrieve key for %s" % name)
assert(key.provider.exists?, "key %s is missing" % name)
}
diff --git a/test/ral/types/user.rb b/test/ral/types/user.rb
index b280acfed..ec9b12923 100755
--- a/test/ral/types/user.rb
+++ b/test/ral/types/user.rb
@@ -449,6 +449,7 @@ class TestUser < Test::Unit::TestCase
# Testing #455
def test_autorequire_with_no_group_should
user = Puppet::Type.type(:user).create(:name => "yaytest", :check => :all)
+ catalog = mk_catalog(user)
assert_nothing_raised do
user.autorequire