summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-12-18 10:57:59 -0600
committerLuke Kanies <luke@madstop.com>2008-12-18 11:10:26 -0600
commit0fc067449a5e6f4941e2dfe232383b94f163b110 (patch)
tree7ee4b5fd9d901f742b85ba8bd394f1b2eea5ae5c /test
parente4ba3db1963081eacc2aef3d865f777b427ef23c (diff)
Fixing all of the test/ tests I broke in previous dev.
Most of these are straightforward changes to the tests, but a couple required small refactorings (e.g., References can now be created with Puppet::Type instances, and they know how to extract the type/title from them). Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/network/handler/resource.rb2
-rwxr-xr-xtest/other/events.rb6
-rwxr-xr-xtest/other/relationships.rb132
-rwxr-xr-xtest/other/transactions.rb16
-rwxr-xr-xtest/ral/manager/attributes.rb21
-rwxr-xr-xtest/ral/manager/type.rb62
-rwxr-xr-xtest/ral/providers/parsedfile.rb8
-rwxr-xr-xtest/ral/type/exec.rb5
-rwxr-xr-xtest/util/settings.rb85
9 files changed, 20 insertions, 317 deletions
diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb
index d766c685d..48e812913 100755
--- a/test/network/handler/resource.rb
+++ b/test/network/handler/resource.rb
@@ -209,7 +209,7 @@ class TestResourceServer < Test::Unit::TestCase
}
bucket = Puppet::TransBucket.new
- bucket.type = "file"
+ bucket.type = "class"
bucket.name = "test"
bucket.push filetrans
diff --git a/test/other/events.rb b/test/other/events.rb
index c4c2a53e6..3f02575d9 100755
--- a/test/other/events.rb
+++ b/test/other/events.rb
@@ -19,7 +19,7 @@ class TestEvents < Test::Unit::TestCase
:name => "echo true",
:path => "/usr/bin:/bin",
:refreshonly => true,
- :subscribe => [[file.class.name, file.name]]
+ :subscribe => Puppet::Resource::Reference.new(file.class.name, file.name)
)
comp = mk_catalog("eventtesting", file, exec)
@@ -39,7 +39,7 @@ class TestEvents < Test::Unit::TestCase
:name => "echo true",
:path => "/usr/bin:/bin",
:refreshonly => true,
- :require => [[file.class.name, file.name]]
+ :require => Puppet::Resource::Reference.new(file.class.name, file.name)
)
@@ -71,7 +71,7 @@ class TestEvents < Test::Unit::TestCase
)
exec[:subscribe] = files.collect { |f|
- ["file", f.name]
+ Puppet::Resource::Reference.new(:file, f.name)
}
comp = mk_catalog(exec, *files)
diff --git a/test/other/relationships.rb b/test/other/relationships.rb
index f007ca1c1..b3a70eeae 100755
--- a/test/other/relationships.rb
+++ b/test/other/relationships.rb
@@ -53,116 +53,11 @@ class TestRelationships < Test::Unit::TestCase
end
end
- # Make sure our various metaparams work correctly. We're just checking
- # here whether they correctly set up the callbacks and the direction of
- # the relationship.
- def test_relationship_metaparams
- out = {:require => false, :subscribe => false,
- :notify => true, :before => true}
- refreshers = [:subscribe, :notify]
- [:require, :subscribe, :notify, :before].each do |param|
- # Create three files to generate our events and three
- # execs to receive them
- files = []
- execs = []
- 3.times do |i|
- files << Puppet::Type.newfile(
- :title => "file#{i}",
- :path => tempfile(),
- :ensure => :file
- )
-
- path = tempfile()
- execs << Puppet::Type.newexec(
- :title => "notifytest#{i}",
- :path => "/usr/bin:/bin",
- :command => "touch #{path}",
- :refreshonly => true
- )
- end
-
- catalog = mk_catalog(*files)
- catalog.add_resource(*execs)
-
- # Add our first relationship
- if out[param]
- files[0][param] = execs[0]
- sources = files[0]
- targets = [execs[0]]
- else
- execs[0][param] = files[0]
- sources = [files[0]]
- targets = execs[0]
- end
- check_relationship(sources, targets, out[param], refreshers.include?(param))
-
- # Now add another relationship
- if out[param]
- files[0][param] = execs[1]
- targets << execs[1]
- assert_equal(targets.collect { |t| [t.class.name, t.title]},
- files[0][param], "Incorrect target list")
- else
- execs[0][param] = files[1]
- sources << files[1]
- assert_equal(sources.collect { |t| [t.class.name, t.title]},
- execs[0][param], "Incorrect source list")
- end
- check_relationship(sources, targets, out[param], refreshers.include?(param))
- end
- end
-
- def test_munge_relationship
- file = Puppet::Type.newfile :path => tempfile(), :mode => 0755
- execs = []
- 3.times do |i|
- execs << Puppet::Type.newexec(:title => "yay#{i}", :command => "/bin/echo yay")
- end
-
- # First try it with one object, specified as a reference and an array
- result = nil
- [execs[0], [:exec, "yay0"], ["exec", "yay0"]].each do |target|
- assert_nothing_raised do
- result = file.send(:munge_relationship, :require, target)
- end
-
- assert_equal([[:exec, "yay0"]], result)
- end
-
- # Now try it with multiple objects
- symbols = execs.collect { |e| [e.class.name, e.title] }
- strings = execs.collect { |e| [e.class.name.to_s, e.title] }
- [execs, symbols, strings].each do |target|
- assert_nothing_raised do
- result = file.send(:munge_relationship, :require, target)
- end
-
- assert_equal(symbols, result)
- end
-
- # Make sure we can mix it up, even though this shouldn't happen
- assert_nothing_raised do
- result = file.send(:munge_relationship, :require, [execs[0], [execs[1].class.name, execs[1].title]])
- end
-
- assert_equal([[:exec, "yay0"], [:exec, "yay1"]], result)
-
- # Finally, make sure that new results get added to old. The only way
- # to get rid of relationships is to delete the parameter.
- file[:require] = execs[0]
-
- assert_nothing_raised do
- result = file.send(:munge_relationship, :require, [execs[1], execs[2]])
- end
-
- assert_equal(symbols, result)
- end
-
def test_autorequire
# We know that execs autorequire their cwd, so we'll use that
path = tempfile()
- file = Puppet::Type.newfile(:title => "myfile", :path => path,
+ file = Puppet::Type.type(:file).new(:title => "myfile", :path => path,
:ensure => :directory)
exec = Puppet::Type.newexec(:title => "myexec", :cwd => path,
:command => "/bin/echo")
@@ -183,32 +78,9 @@ class TestRelationships < Test::Unit::TestCase
end
end
- def test_requires?
- # Test the first direction
- file1 = Puppet::Type.newfile(:title => "one", :path => tempfile,
- :ensure => :directory)
- file2 = Puppet::Type.newfile(:title => "two", :path => tempfile,
- :ensure => :directory)
-
- file1[:require] = file2
- assert(file1.requires?(file2), "requires? failed to catch :require relationship")
- file1.delete(:require)
- assert(! file1.requires?(file2), "did not delete relationship")
- file1[:subscribe] = file2
- assert(file1.requires?(file2), "requires? failed to catch :subscribe relationship")
- file1.delete(:subscribe)
- assert(! file1.requires?(file2), "did not delete relationship")
- file2[:before] = file1
- assert(file1.requires?(file2), "requires? failed to catch :before relationship")
- file2.delete(:before)
- assert(! file1.requires?(file2), "did not delete relationship")
- file2[:notify] = file1
- assert(file1.requires?(file2), "requires? failed to catch :notify relationship")
- end
-
# Testing #411. It was a problem with builddepends.
def test_missing_deps
- file = Puppet::Type.newfile :path => tempfile, :require => ["file", "/no/such/file"]
+ file = Puppet::Type.type(:file).new :path => tempfile, :require => Puppet::Resource::Reference.new("file", "/no/such/file")
assert_raise(Puppet::Error) do
file.builddepends
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 568660848..6145b19c5 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -158,12 +158,12 @@ class TestTransactions < Test::Unit::TestCase
file = Puppet::Type.type(:file).new(:title => "file", :path => path, :content => "yayness")
first = Puppet::Type.type(:exec).new(:title => "first",
:command => "/bin/echo first > #{firstpath}",
- :subscribe => [:file, path],
+ :subscribe => Puppet::Resource::Reference.new(:file, path),
:refreshonly => true
)
second = Puppet::Type.type(:exec).new(:title => "second",
:command => "/bin/echo second > #{secondpath}",
- :subscribe => [:exec, "first"],
+ :subscribe => Puppet::Resource::Reference.new(:exec, "first"),
:refreshonly => true
)
@@ -301,7 +301,7 @@ class TestTransactions < Test::Unit::TestCase
@@tmpfiles << execfile
# 'subscribe' expects an array of arrays
- exec[:subscribe] = [[file.class.name,file.name]]
+ exec[:subscribe] = Puppet::Resource::Reference.new(file.class.name,file.name)
exec[:refreshonly] = true
assert_nothing_raised() {
@@ -385,13 +385,13 @@ class TestTransactions < Test::Unit::TestCase
:path => ENV["PATH"],
:command => "touch %s" % file1,
:refreshonly => true,
- :subscribe => [:file, path]
+ :subscribe => Puppet::Resource::Reference.new(:file, path)
)
exec2 = Puppet::Type.type(:exec).new(
:path => ENV["PATH"],
:command => "touch %s" % file2,
:refreshonly => true,
- :subscribe => [:file, path]
+ :subscribe => Puppet::Resource::Reference.new(:file, path)
)
assert_apply(file, exec1, exec2)
@@ -444,7 +444,7 @@ class TestTransactions < Test::Unit::TestCase
:name => "touch %s" % fname,
:path => "/usr/bin:/bin",
:schedule => "monthly",
- :subscribe => ["file", file.name]
+ :subscribe => Puppet::Resource::Reference.new("file", file.name)
)
config = mk_catalog(file, exec)
@@ -791,6 +791,10 @@ class TestTransactions < Test::Unit::TestCase
attr_accessor :refreshed, :testing
newparam(:name) {}
newproperty(:testing) do
+ def retrieve
+ :eh
+ end
+
def sync
# noop
:ran_testing
diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb
index cad0f2f7a..05f8bc97f 100755
--- a/test/ral/manager/attributes.rb
+++ b/test/ral/manager/attributes.rb
@@ -184,27 +184,6 @@ class TestTypeAttributes < Test::Unit::TestCase
end
end
- # Make sure eachattr is called in the parameter order.
- def test_eachattr
- type = mktype
- name = type.newparam(:name) {}
- one = type.newparam(:one) {}
- two = type.newproperty(:two) {}
- type.provide(:testing) {}
- provider = type.attrclass(:provider)
- should = [[name, :param], [provider, :param], [two, :property], [one, :param]]
- assert_nothing_raised do
- result = nil
- type.eachattr do |obj, name|
- result = [obj, name]
- shouldary = should.shift
- assert_equal(shouldary, result, "Did not get correct parameter")
- break if should.empty?
- end
- end
- assert(should.empty?, "Did not get all of the parameters.")
- end
-
# Make sure newattr handles required features correctly.
def test_newattr_and_required_features
# Make a type with some features
diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb
index d6b7b2a1d..0a0e13e39 100755
--- a/test/ral/manager/type.rb
+++ b/test/ral/manager/type.rb
@@ -137,36 +137,6 @@ class TestType < Test::Unit::TestCase
}
end
- # Verify that requirements don't depend on file order
- def test_prereqorder
- one = tempfile()
- two = tempfile()
-
- twoobj = nil
- oneobj = nil
- assert_nothing_raised("Could not create prereq that doesn't exist yet") {
- twoobj = Puppet::Type.type(:file).new(
- :name => two,
- :require => [:file, one]
- )
- }
-
- assert_nothing_raised {
- oneobj = Puppet::Type.type(:file).new(
- :name => one
- )
- }
-
- comp = mk_catalog(twoobj, oneobj)
-
- assert_nothing_raised {
- comp.finalize
- }
-
-
- assert(twoobj.requires?(oneobj), "Requirement was not created")
- end
-
def test_ensuredefault
user = nil
assert_nothing_raised {
@@ -337,17 +307,6 @@ class TestType < Test::Unit::TestCase
assert_equal(path, file[:name], "Did not get correct name")
end
- def test_multiplenames
- obj = nil
- path = tempfile()
- assert_raise ArgumentError do
- obj = Puppet::Type.type(:file).new(
- :name => path,
- :path => path
- )
- end
- end
-
# Make sure default providers behave correctly
def test_defaultproviders
# Make a fake type
@@ -507,27 +466,6 @@ class TestType < Test::Unit::TestCase
assert_equal("//Good[bad]/Exec[exec6]", exec.path)
end
- def test_evaluate
- faketype = Puppet::Type.newtype(:faketype) do
- newparam(:name) {}
- end
- cleanup { Puppet::Type.rmtype(:faketype) }
- faketype.provide(:fake) do
- def prefetch
- end
- end
-
- obj = faketype.create :name => "yayness", :provider => :fake
- assert(obj, "did not create object")
-
- obj.provider.expects(:prefetch)
- obj.expects(:retrieve)
- obj.expects(:propertychanges).returns([])
- obj.expects(:cache)
-
- obj.evaluate
- end
-
# Partially test #704, but also cover the rest of the schedule management bases.
def test_schedule
schedule = Puppet::Type.type(:schedule).new(:name => "maint")
diff --git a/test/ral/providers/parsedfile.rb b/test/ral/providers/parsedfile.rb
index aef2a5492..d57a873ea 100755
--- a/test/ral/providers/parsedfile.rb
+++ b/test/ral/providers/parsedfile.rb
@@ -608,13 +608,9 @@ class TestParsedFile < Test::Unit::TestCase
prov.prefetch
# Now make a resource
- bill = nil
- assert_nothing_raised do
- bill = @type.new :name => "bill"
- end
+ bill = @type.new :name => "bill"
- assert_equal("a", bill.provider.one,
- "Record was not found in memory")
+ assert_equal("a", bill.provider.one, "Record was not found in memory")
end
# Make sure invalid fields always show up as insync
diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb
index f04b3c908..e156beaae 100755
--- a/test/ral/type/exec.rb
+++ b/test/ral/type/exec.rb
@@ -195,7 +195,7 @@ class TestExec < Test::Unit::TestCase
exec = Puppet::Type.type(:exec).new(
:command => oexe,
- :require => [:file, oexe]
+ :require => Puppet::Resource::Reference.new(:file, oexe)
)
comp = mk_catalog("Testing", file, exec)
@@ -254,7 +254,6 @@ class TestExec < Test::Unit::TestCase
# Verify we don't require ourselves
assert(! rels.detect { |r| r.source == ofile }, "Exec incorrectly required mentioned file")
- assert(!exec.requires?(ofile), "Exec incorrectly required file")
# We not longer autorequire inline files
assert_nothing_raised do
@@ -419,7 +418,7 @@ class TestExec < Test::Unit::TestCase
:path => basedir,
:recurse => true,
:mode => "755",
- :require => ["exec", "mkdir"]
+ :require => Puppet::Resource::Reference.new("exec", "mkdir")
)
}
diff --git a/test/util/settings.rb b/test/util/settings.rb
index 286b14800..c4096f0bc 100755
--- a/test/util/settings.rb
+++ b/test/util/settings.rb
@@ -468,91 +468,6 @@ yay = /a/path
assert_equal(should, result, "Add args functional test failed")
end
- def test_usesection
- # We want to make sure that config processes do not result in graphing.
- Puppet[:graphdir] = tempfile()
- Puppet[:graph] = true
- Dir.mkdir(Puppet[:graphdir])
- c = mkconfig
-
- dir = tempfile()
- file = "$mydir/myfile"
- realfile = File.join(dir, "myfile")
- otherfile = File.join(dir, "otherfile")
- section = "testing"
- assert_nothing_raised {
- @config.setdefaults(section,
- :mydir => [dir, "A dir arg"],
- :otherfile => {
- :default => "$mydir/otherfile",
- :create => true,
- :desc => "A file arg"
- },
- :myfile => [file, "A file arg"]
- )
- }
-
- assert_nothing_raised("Could not use a section") {
- @config.use(section)
- }
-
- assert_nothing_raised("Could not reuse a section") {
- @config.use(section)
- }
-
- # Make sure it didn't graph anything, which is the only real way
- # to test that the transaction was marked as a configurator.
- assert(Dir.entries(Puppet[:graphdir]).reject { |f| f =~ /^\.\.?$/ }.empty?, "Graphed config process")
-
- assert(FileTest.directory?(dir), "Did not create directory")
- assert(FileTest.exists?(otherfile), "Did not create file")
- assert(!FileTest.exists?(realfile), "Created file")
- end
-
- def test_setdefaultsarray
- c = mkconfig
-
- assert_nothing_raised {
- @config.setdefaults("yay",
- :a => [false, "some value"],
- :b => ["/my/file", "a file"]
- )
- }
-
- assert_equal(false, @config[:a], "Values are not equal")
- assert_equal("/my/file", @config[:b], "Values are not equal")
- end
-
- def test_setdefaultshash
- c = mkconfig
-
- assert_nothing_raised {
- @config.setdefaults("yay",
- :a => {:default => false, :desc => "some value"},
- :b => {:default => "/my/file", :desc => "a file"}
- )
- }
-
- assert_equal(false, @config[:a], "Values are not equal")
- assert_equal("/my/file", @config[:b], "Values are not equal")
- end
-
- def test_notmanagingdev
- c = mkconfig
- path = "/dev/testing"
- @config.setdefaults(:test,
- :file => {
- :default => path,
- :mode => 0640,
- :desc => 'yay'
- }
- )
-
- config = @config.to_catalog
-
- assert(! config.resource(:file, "/dev/testing"), "Created dev file")
- end
-
def test_groupsetting
cfile = tempfile()