summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJacob Helwig <jacob@puppetlabs.com>2011-02-01 14:43:47 -0800
committerJacob Helwig <jacob@puppetlabs.com>2011-02-01 14:57:13 -0800
commit76788f80aab15e5ef6487788132b87ecc6ddd9ac (patch)
tree4eec377de6bd844013ee196b0a2091d245751c2d /spec
parentd6572921832cc0df22e13d55c3bc090b74155b91 (diff)
downloadpuppet-76788f80aab15e5ef6487788132b87ecc6ddd9ac.tar.gz
puppet-76788f80aab15e5ef6487788132b87ecc6ddd9ac.tar.xz
puppet-76788f80aab15e5ef6487788132b87ecc6ddd9ac.zip
(#5566) Treat source only File checksums as syntax errors when used with content
Certain checksum types (ctime, mtime) only make sense when used with the 'source' File parameter, since there is no way to check them on raw strings. Given the limitations of the current checksumming implementations, it is likely to introduce unexpected behavior when using the 'none' checksum type and either one of the 'source', and 'content' File parameters. Because of this, it is now a syntax error to use a checksum of 'none' with either parameter. Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/type/file_spec.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb
index 944bd6bac..698dff52a 100755
--- a/spec/unit/type/file_spec.rb
+++ b/spec/unit/type/file_spec.rb
@@ -823,6 +823,75 @@ describe Puppet::Type.type(:file) do
end
end
+ describe "when specifying both source, and content properties" do
+ before do
+ @file[:source] = '/one'
+ @file[:content] = 'file contents'
+ end
+
+ it "should raise an exception" do
+ lambda {@file.validate }.should raise_error(/You cannot specify more than one of/)
+ end
+ end
+
+ describe "when using source" do
+ before do
+ @file[:source] = '/one'
+ end
+ Puppet::Type::File::ParameterChecksum.value_collection.values.reject {|v| v == :none}.each do |checksum_type|
+ describe "with checksum '#{checksum_type}'" do
+ before do
+ @file[:checksum] = checksum_type
+ end
+
+ it 'should validate' do
+
+ lambda { @file.validate }.should_not raise_error
+ end
+ end
+ end
+
+ describe "with checksum 'none'" do
+ before do
+ @file[:checksum] = :none
+ end
+
+ it 'should raise an exception when validating' do
+ lambda { @file.validate }.should raise_error(/You cannot specify source when using checksum 'none'/)
+ end
+ end
+ end
+
+ describe "when using content" do
+ SOURCE_ONLY_CHECKSUMS = [:none, :ctime, :mtime]
+
+ before do
+ @file[:content] = 'file contents'
+ end
+
+ (Puppet::Type::File::ParameterChecksum.value_collection.values - SOURCE_ONLY_CHECKSUMS).each do |checksum_type|
+ describe "with checksum '#{checksum_type}'" do
+ before do
+ @file[:checksum] = checksum_type
+ end
+
+ it 'should validate' do
+ lambda { @file.validate }.should_not raise_error
+ end
+ end
+ end
+
+ SOURCE_ONLY_CHECKSUMS.each do |checksum_type|
+ describe "with checksum '#{checksum_type}'" do
+ it 'should raise an exception when validating' do
+ @file[:checksum] = checksum_type
+
+ lambda { @file.validate }.should raise_error(/You cannot specify content when using checksum '#{checksum_type}'/)
+ end
+ end
+ end
+ end
+
describe "when returning resources with :eval_generate" do
before do
@graph = stub 'graph', :add_edge => nil