summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-29 18:16:16 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-29 18:16:16 +0000
commit54c458ce690231980cb8f0c0a691880a4f3b788c (patch)
tree065e6903a741a6d463bb69bdd90afcb25a112b2f
parent04017b3399f8e0b2421b38864fa6593dfc3eec78 (diff)
downloadpuppet-54c458ce690231980cb8f0c0a691880a4f3b788c.tar.gz
puppet-54c458ce690231980cb8f0c0a691880a4f3b788c.tar.xz
puppet-54c458ce690231980cb8f0c0a691880a4f3b788c.zip
Fixing #438.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2112 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/type/pfile.rb12
-rwxr-xr-xtest/types/file.rb16
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index bab737f4f..08d3d5a1a 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -224,10 +224,16 @@ module Puppet
end
end
end
+
+ CREATORS = [:content, :source, :target]
validate do
- if self[:content] and self[:source]
- self.fail "You cannot specify both content and a source"
+ count = 0
+ CREATORS.each do |param|
+ count += 1 if self.should(param)
+ end
+ if count > 1
+ self.fail "You cannot specify more than one of %s" % CREATORS.collect { |p| p.to_s}.join(", ")
end
end
@@ -1088,7 +1094,7 @@ module Puppet
require 'puppet/type/pfile/checksum'
require 'puppet/type/pfile/content' # can create the file
require 'puppet/type/pfile/source' # can create the file
- require 'puppet/type/pfile/target'
+ require 'puppet/type/pfile/target' # creates a different type of file
require 'puppet/type/pfile/ensure' # can create the file
require 'puppet/type/pfile/owner'
require 'puppet/type/pfile/group'
diff --git a/test/types/file.rb b/test/types/file.rb
index e1cb06978..0e9fff23a 100755
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -1932,6 +1932,22 @@ class TestFile < Test::Unit::TestCase
assert(Puppet::Type.type(:file)[path], "could not look up file via path %s" % path)
end
end
+
+ # Testing #438
+ def test_creating_states_conflict
+ file = tempfile()
+ first = tempfile()
+ second = tempfile()
+ params = [:content, :source, :target]
+ params.each do |param|
+ params.each do |other|
+ next if other == param
+ assert_raise(Puppet::Error, "%s and %s did not conflict" % [param, other]) do
+ Puppet::Type.newfile(:path => file, other => first, param => second)
+ end
+ end
+ end
+ end
end
# $Id$