diff options
-rw-r--r-- | lib/puppet/provider/nameservice/directoryservice.rb | 3 | ||||
-rw-r--r-- | lib/puppet/type/resources.rb | 1 | ||||
-rw-r--r-- | spec/unit/type/resources.rb | 27 | ||||
-rwxr-xr-x | test/ral/type/resources.rb | 21 |
4 files changed, 33 insertions, 19 deletions
diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index a20a8a96e..ecd5fa6f4 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -369,6 +369,9 @@ class DirectoryService < Puppet::Provider::NameService type_properties.delete(:ensure) if type_properties.include? :ensure type_properties << :guid # append GeneratedUID so we just get the report here @property_value_cache_hash = self.class.single_report(@resource[:name], *type_properties) + [:uid, :gid].each do |param| + @property_value_cache_hash[param] = @property_value_cache_hash[param].to_i if @property_value_cache_hash and @property_value_cache_hash.include?(param) + end end return @property_value_cache_hash end diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index c0d892bb8..358ad603b 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -137,6 +137,7 @@ Puppet::Type.newtype(:resources) do return false end + p current_values[resource.property(:uid)] if current_values[resource.property(:uid)] <= self[:unless_system_user] return false else diff --git a/spec/unit/type/resources.rb b/spec/unit/type/resources.rb new file mode 100644 index 000000000..2c323ba24 --- /dev/null +++ b/spec/unit/type/resources.rb @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +resources = Puppet::Type.type(:resources) + +# There are still plenty of tests to port over from test/. +describe resources do + describe "when initializing" do + before do + resources.clear + end + + it "should fail if the specified resource type does not exist" do + Puppet::Type.expects(:type).with("nosuchtype").returns nil + lambda { resources.create :name => "nosuchtype" }.should raise_error(Puppet::Error) + end + + it "should not fail when the specified resource type exists" do + lambda { resources.create :name => "file" }.should_not raise_error + end + + it "should set its :resource_type attribute" do + resources.create(:name => "file").resource_type.should == Puppet::Type.type(:file) + end + end +end diff --git a/test/ral/type/resources.rb b/test/ral/type/resources.rb index 0663fe795..552f51253 100755 --- a/test/ral/type/resources.rb +++ b/test/ral/type/resources.rb @@ -58,24 +58,7 @@ class TestResources < Test::Unit::TestCase super @type = Puppet::Type.type(:resources) end - - def test_initialize - assert(@type, "Could not retrieve resources type") - # Make sure we can't create them for types that don't exist - assert_raise(Puppet::Error) do - @type.create :name => "thereisnotypewiththisname" - end - - # Now make sure it works for a normal type - usertype = nil - assert_nothing_raised do - usertype = @type.create :name => "user" - end - assert(usertype, "did not create user resource type") - assert_equal(Puppet::Type.type(:user), usertype.resource_type, - "resource_type was not set correctly") - end - + def test_purge # Create a purgeable type mkpurgertype @@ -149,7 +132,7 @@ class TestResources < Test::Unit::TestCase assert_nothing_raised { assert(res.check("A String"), "String failed check") - assert(res.check(Puppet::Type.newfile(:path => tempfile())), "File failed check") + assert(res.check(Puppet::Type.type(:file).create(:path => tempfile())), "File failed check") assert(res.check(Puppet::Type.type(:user).create(:name => "yayness")), "User failed check in package") } |