summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-05-15 19:22:36 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-05-15 19:22:36 +0000
commitdbedcd7b9892bc41728a4f334464f152d09d54fc (patch)
tree66e06fa8fec48ea00491a728ed24906e6b810812
parent28f7d6c7ebd56da3014464c82c73a4f98f3406ea (diff)
downloadpuppet-dbedcd7b9892bc41728a4f334464f152d09d54fc.tar.gz
puppet-dbedcd7b9892bc41728a4f334464f152d09d54fc.tar.xz
puppet-dbedcd7b9892bc41728a4f334464f152d09d54fc.zip
A round of fixes so unit tests pass; most of the failures were from the merging of the transaction-refactor branch
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2517 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/network/client/master.rb2
-rwxr-xr-xlib/puppet/network/handler/report.rb2
-rwxr-xr-xlib/puppet/type/cron.rb5
-rwxr-xr-xlib/puppet/type/host.rb2
-rwxr-xr-xlib/puppet/type/mount.rb2
-rwxr-xr-xlib/puppet/type/port.rb2
-rw-r--r--lib/puppet/type/resources.rb4
-rw-r--r--lib/puppet/type/yumrepo.rb1
-rwxr-xr-xlib/puppet/util/posix.rb7
-rwxr-xr-xtest/network/handler/resource.rb3
-rwxr-xr-xtest/other/propertychange.rb7
-rwxr-xr-xtest/other/transactions.rb13
-rwxr-xr-xtest/util/posixtest.rb9
13 files changed, 28 insertions, 31 deletions
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index e7739ba34..7eb009b2d 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -544,7 +544,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# Have the facts changed since we last compiled?
def facts_changed?(facts)
- oldfacts = Puppet::Util::Storage.cache(:configuration)[:facts].dup
+ oldfacts = (Puppet::Util::Storage.cache(:configuration)[:facts] || {}).dup
newfacts = facts.dup
self.class.dynamic_facts.each do |fact|
[oldfacts, newfacts].each do |facthash|
diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb
index ce5176a36..827f5978b 100755
--- a/lib/puppet/network/handler/report.rb
+++ b/lib/puppet/network/handler/report.rb
@@ -65,7 +65,7 @@ class Puppet::Network::Handler
# List each of the reports.
def self.reports
instance_loader(:report).loadall
- @reports.keys
+ loaded_instances(:report)
end
def initialize(*args)
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index cf4f7cc33..ff0ef8f7d 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -2,7 +2,6 @@ require 'etc'
require 'facter'
require 'puppet/type/property'
require 'puppet/util/filetype'
-require 'puppet/type/parsedtype'
Puppet::Type.newtype(:cron) do
@doc = "Installs and manages cron jobs. All fields except the command
@@ -29,9 +28,7 @@ Puppet::Type.newtype(:cron) do
ensurable
# A base class for all of the Cron parameters, since they all have
- # similar argument checking going on. We're stealing the base class
- # from parsedtype, and we should probably subclass Cron from there,
- # but it was just too annoying to do.
+ # similar argument checking going on.
class CronParam < Puppet::Property
class << self
attr_accessor :boundaries, :default
diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb
index 6ff02c155..6a2e9082d 100755
--- a/lib/puppet/type/host.rb
+++ b/lib/puppet/type/host.rb
@@ -1,5 +1,3 @@
-require 'puppet/type/parsedtype'
-
module Puppet
newtype(:host) do
ensurable
diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb
index dd70f87a6..08cc42cda 100755
--- a/lib/puppet/type/mount.rb
+++ b/lib/puppet/type/mount.rb
@@ -1,5 +1,3 @@
-require 'puppet/type/parsedtype'
-
module Puppet
# We want the mount to refresh when it changes.
newtype(:mount, :self_refresh => true) do
diff --git a/lib/puppet/type/port.rb b/lib/puppet/type/port.rb
index 19c3dae76..dc2220070 100755
--- a/lib/puppet/type/port.rb
+++ b/lib/puppet/type/port.rb
@@ -1,5 +1,3 @@
-require 'puppet/type/parsedtype'
-
#module Puppet
# newtype(:port) do
# @doc = "Installs and manages port entries. For most systems, these
diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb
index b314c9441..ca88a7c31 100644
--- a/lib/puppet/type/resources.rb
+++ b/lib/puppet/type/resources.rb
@@ -124,6 +124,8 @@ Puppet::Type.newtype(:resources) do
@resource_type
end
+ # Make sure we don't purge users below a certain uid, if the check
+ # is enabled.
def user_check(resource)
return true unless self[:name] == "user"
return true unless self[:unless_system_user]
@@ -134,6 +136,8 @@ Puppet::Type.newtype(:resources) do
if system_users().include?(resource[:name])
return false
end
+
+ resource.info current_values.inspect
if current_values[resource.property(:uid)] <= self[:unless_system_user]
return false
diff --git a/lib/puppet/type/yumrepo.rb b/lib/puppet/type/yumrepo.rb
index a344d2c3b..ac8704434 100644
--- a/lib/puppet/type/yumrepo.rb
+++ b/lib/puppet/type/yumrepo.rb
@@ -2,7 +2,6 @@
require 'puppet/propertychange'
require 'puppet/util/inifile'
-require 'puppet/type/parsedtype'
module Puppet
# A property for one entry in a .ini-style file
diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb
index 9131b394d..06df632a9 100755
--- a/lib/puppet/util/posix.rb
+++ b/lib/puppet/util/posix.rb
@@ -3,6 +3,9 @@ module Puppet::Util::POSIX
# Retrieve a field from a POSIX Etc object. The id can be either an integer
# or a name. This only works for users and groups.
def get_posix_field(space, field, id)
+ unless id
+ raise ArgumentError, "Did not get id"
+ end
if id =~ /^\d+$/
id = Integer(id)
end
@@ -37,7 +40,7 @@ module Puppet::Util::POSIX
obj = typeklass.find { |obj|
if id =~ /^\d+$/
obj.should(chkfield).to_s == id ||
- obj.is(chkfield).to_s == id
+ obj.provider.send(chkfield) == id
else
obj[:name] == id
end
@@ -84,4 +87,4 @@ module Puppet::Util::POSIX
end
end
-# $Id$ \ No newline at end of file
+# $Id$
diff --git a/test/network/handler/resource.rb b/test/network/handler/resource.rb
index b89eacac5..8d1fa1087 100755
--- a/test/network/handler/resource.rb
+++ b/test/network/handler/resource.rb
@@ -89,9 +89,8 @@ class TestResourceServer < Test::Unit::TestCase
assert_events([:file_created], object)
else
assert_nothing_raised {
- object.retrieve
+ assert(object.insync?(object.retrieve), "Object was not in sync")
}
- assert(object.insync?, "Object was not in sync")
end
assert(FileTest.exists?(file), "File did not get recreated")
diff --git a/test/other/propertychange.rb b/test/other/propertychange.rb
index 97ee3268c..31321753b 100755
--- a/test/other/propertychange.rb
+++ b/test/other/propertychange.rb
@@ -10,7 +10,7 @@ require 'puppettest'
class TestPropertyChange < Test::Unit::TestCase
include PuppetTest
class FakeProperty < Puppet::Type::Property
- attr_accessor :is, :should, :parent
+ attr_accessor :is, :should, :resource
attr_reader :noop
def change_to_s(currentvalue, newvalue)
"fake change"
@@ -52,10 +52,10 @@ class TestPropertyChange < Test::Unit::TestCase
end
def mkchange
- property = FakeProperty.new :parent => "fakeparent"
+ property = FakeProperty.new :resource => "fakeparent"
property.is = :start
property.should = :finish
- property.parent = :parent
+ property.resource = :parent
change = nil
assert_nothing_raised do
change = Puppet::PropertyChange.new(property, :start)
@@ -125,7 +125,6 @@ class TestPropertyChange < Test::Unit::TestCase
Puppet[:noop] = true
change.property.noop = true
- p change.property.noop
assert(change.noop, "did not set noop")
assert(change.skip?, "setting noop did not mark change for skipping")
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 3a9ba3d79..1e0b6377d 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -248,8 +248,9 @@ class TestTransactions < Test::Unit::TestCase
assert_nothing_raised() {
check.each { |property|
- assert(file[property])
- properties[property] = file[property]
+ value = file.value(property)
+ assert(value)
+ properties[property] = value
}
}
@@ -277,7 +278,7 @@ class TestTransactions < Test::Unit::TestCase
}
properties.each { |property,value|
assert_equal(
- value,file.is(property), "File %s remained %s" % [property, file.is(property)]
+ value, file.value(property), "File %s remained %s" % [property, file.value(property)]
)
}
end
@@ -310,7 +311,7 @@ class TestTransactions < Test::Unit::TestCase
}
check.each { |property|
- properties[property] = file[property]
+ properties[property] = file.value(property)
}
assert_nothing_raised() {
file[:mode] = "755"
@@ -766,7 +767,7 @@ class TestTransactions < Test::Unit::TestCase
type = mkreducer do
def evaluate
return Puppet::PropertyChange.new(Fakeprop.new(
- :path => :path, :is => :is, :should => :should, :name => self.name, :parent => "a parent"), :is)
+ :path => :path, :is => :is, :should => :should, :name => self.name, :resource => "a parent"), :is)
end
end
@@ -778,7 +779,7 @@ class TestTransactions < Test::Unit::TestCase
assert_nothing_raised do
trans.eval_resource(resource)
end
-
+
changes = trans.instance_variable_get("@changes")
assert(changes.length > 0, "did not get any changes")
diff --git a/test/util/posixtest.rb b/test/util/posixtest.rb
index 7939afd46..8c4174144 100755
--- a/test/util/posixtest.rb
+++ b/test/util/posixtest.rb
@@ -90,8 +90,9 @@ class TestPosixUtil < Test::Unit::TestCase
:check => [:gid]
)
obj.setdefaults
- obj.retrieve
- id = obj.is(:gid)
+ current = obj.retrieve
+ id = nil
+ current.find { |prop, value| id = value if prop.name == :gid }
gid = nil
assert_nothing_raised {
gid = Puppet::Util.gid(id)
@@ -146,7 +147,7 @@ class TestPosixUtil < Test::Unit::TestCase
)
obj.setdefaults
obj.retrieve
- id = obj.is(:uid)
+ id = obj.provider.uid
uid = nil
assert_nothing_raised {
uid = Puppet::Util.uid(id)
@@ -170,4 +171,4 @@ class TestPosixUtil < Test::Unit::TestCase
end
end
-# $Id$ \ No newline at end of file
+# $Id$