[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

James Turnbull james at lovedthanlost.net
Fri Jan 23 14:21:44 UTC 2009


The following commit has been merged in the master branch:
commit 5bd27c8b81c3250dd04307460868ff113b64190c
Author: Luke Kanies <luke at madstop.com>
Date:   Tue Nov 25 13:21:32 2008 -0600

    Partially fixing #1772 - broken 'resources' tests.
    
    The main problem was that the directory_services user provider was returning
    a string for its uid instead of an integer.  I also began a 'resources'
    spec file.
    
    Signed-off-by: Luke Kanies <luke at madstop.com>

diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb
index a20a8a9..ecd5fa6 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 c0d892b..358ad60 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 0000000..2c323ba
--- /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 0663fe7..552f512 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")
         }
         

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list