[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585
Luke Kanies
luke at madstop.com
Fri Jan 23 14:21:20 UTC 2009
The following commit has been merged in the master branch:
commit 2153baed8c6b99f9b77ed2f63fb24433bd72058c
Author: Luke Kanies <luke at madstop.com>
Date: Wed Oct 8 12:14:11 2008 -0500
Fixing #1640 - file groups now no longer get set on every run
(this was a regression caused by other work I did).
Signed-off-by: Luke Kanies <luke at madstop.com>
diff --git a/lib/puppet/type/file/group.rb b/lib/puppet/type/file/group.rb
index 75beb53..56883ad 100755
--- a/lib/puppet/type/file/group.rb
+++ b/lib/puppet/type/file/group.rb
@@ -46,6 +46,21 @@ module Puppet
end
end
+ def insync?(current)
+ @should.each do |value|
+ if value =~ /^\d+$/
+ gid = Integer(value)
+ elsif value.is_a?(String)
+ fail "Could not find group %s" % value unless gid = gid(value)
+ else
+ gid = value
+ end
+
+ return true if gid == current
+ end
+ return false
+ end
+
def retrieve
return :absent unless stat = resource.stat(false)
diff --git a/spec/unit/type/file/group.rb b/spec/unit/type/file/group.rb
index 2b47c75..856b05b 100755
--- a/spec/unit/type/file/group.rb
+++ b/spec/unit/type/file/group.rb
@@ -6,7 +6,7 @@ property = Puppet::Type.type(:file).attrclass(:group)
describe property do
before do
- @resource = mock 'resource'
+ @resource = stub 'resource', :line => "foo", :file => "bar"
@resource.stubs(:[]).returns "foo"
@resource.stubs(:[]).with(:path).returns "/my/file"
@group = property.new :resource => @resource
@@ -53,6 +53,37 @@ describe property do
end
end
+ describe "when determining if the file is in sync" do
+ it "should directly compare the group values if the desired group is an integer" do
+ @group.should = [10]
+ @group.must be_insync(10)
+ end
+
+ it "should treat numeric strings as integers" do
+ @group.should = ["10"]
+ @group.must be_insync(10)
+ end
+
+ it "should convert the group name to an integer if the desired group is a string" do
+ @group.expects(:gid).with("foo").returns 10
+ @group.should = %w{foo}
+
+ @group.must be_insync(10)
+ end
+
+ it "should fail if it cannot convert a group name to an integer" do
+ @group.expects(:gid).with("foo").returns nil
+ @group.should = %w{foo}
+
+ lambda { @group.insync?(10) }.should raise_error(Puppet::Error)
+ end
+
+ it "should return false if the groups are not equal" do
+ @group.should = [10]
+ @group.should_not be_insync(20)
+ end
+ end
+
describe "when changing the group" do
before do
@group.should = %w{one}
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list