summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorlamont-granquist <lamont@scriptkiddie.org>2014-08-09 15:48:27 -0700
committerlamont-granquist <lamont@scriptkiddie.org>2014-08-09 15:48:27 -0700
commite2a6b85f5b095f2350fa24f8e825fa22660fcbc7 (patch)
tree2d05c53281429f9a8e57695b3bb803807a146fe7 /spec
parent219cb7d209611abb348749b9b342e75a71e90b1d (diff)
parent7611a605420b47eed8da6e1bc366212775978cfc (diff)
downloadchef-e2a6b85f5b095f2350fa24f8e825fa22660fcbc7.tar.gz
Merge pull request #1715 from opscode/lcg/file-provider-fixes
Lcg/file provider fixes
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/resource/remote_file_spec.rb13
-rw-r--r--spec/support/shared/functional/file_resource.rb10
-rw-r--r--spec/support/shared/unit/provider/file.rb10
3 files changed, 28 insertions, 5 deletions
diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb
index 6385efd563..ccdf1cb812 100644
--- a/spec/functional/resource/remote_file_spec.rb
+++ b/spec/functional/resource/remote_file_spec.rb
@@ -73,7 +73,6 @@ describe Chef::Resource::RemoteFile do
it "does not fetch the file" do
resource.run_action(:create)
end
-
end
context "when using normal encoding" do
@@ -225,5 +224,17 @@ describe Chef::Resource::RemoteFile do
end
end
+ describe "when the download of the source raises an exception" do
+ let(:source) { 'http://localhost:0000/seattle_capo.png' }
+
+ before do
+ File.should_not exist(path)
+ end
+
+ it "should not create the file" do
+ expect{ resource.run_action(:create) }.to raise_error
+ File.should_not exist(path)
+ end
+ end
end
end
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index 02e430d1e7..804830fcdc 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -96,6 +96,16 @@ shared_examples_for "a file with the wrong content" do
selinux_security_context_restored?(path).should be_true
end
end
+
+ context "with a checksum that does not match the content to deploy" do
+ before do
+ resource.checksum("aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA")
+ end
+
+ it "raises an exception" do
+ expect{ resource.run_action(:create) }.to raise_error(Chef::Exceptions::ChecksumMismatch)
+ end
+ end
end
describe "when running action :create_if_missing" do
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index 02f68e0acc..85c8e2fb34 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -460,17 +460,19 @@ shared_examples_for Chef::Provider::File do
context "when the file exists" do
before { setup_normal_file }
it "should not create the file" do
+ provider.load_current_resource
provider.deployment_strategy.should_not_receive(:create).with(resource_path)
provider.send(:do_create_file)
- provider.send(:file_created?).should == false
+ provider.send(:needs_creating?).should == false
end
end
context "when the file does not exist" do
before { setup_missing_file }
it "should create the file" do
+ provider.load_current_resource
provider.deployment_strategy.should_receive(:create).with(resource_path)
provider.send(:do_create_file)
- provider.send(:file_created?).should == true
+ provider.send(:needs_creating?).should == true
end
end
end
@@ -503,7 +505,7 @@ shared_examples_for Chef::Provider::File do
provider.deployment_strategy.should_receive(:deploy).with(tempfile_path, normalized_path)
end
context "when the file was created" do
- before { provider.should_receive(:file_created?).at_least(:once).and_return(true) }
+ before { provider.should_receive(:needs_creating?).at_least(:once).and_return(true) }
it "does not backup the file and does not produce a diff for reporting" do
provider.should_not_receive(:do_backup)
provider.send(:do_contents_changes)
@@ -511,7 +513,7 @@ shared_examples_for Chef::Provider::File do
end
end
context "when the file was not created" do
- before { provider.should_receive(:file_created?).at_least(:once).and_return(false) }
+ before { provider.should_receive(:needs_creating?).at_least(:once).and_return(false) }
it "backs up the file and produces a diff for reporting" do
provider.should_receive(:do_backup)
provider.send(:do_contents_changes)