diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-11-14 12:35:05 -0800 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-11-14 12:35:05 -0800 |
commit | f5ec7e9cc0e269eaac284d87f3c3b33a0cf68b6a (patch) | |
tree | d625255c4b47ed9c37740c478e3adccf71eb1c17 /spec/unit/provider/file/content_spec.rb | |
parent | 88a210b46a02aa82f8bf80fab7091b23da7720a3 (diff) | |
download | chef-f5ec7e9cc0e269eaac284d87f3c3b33a0cf68b6a.tar.gz |
Introduct :auto mode for :file_staging_uses_destdir which tries the dest_dir first and falls back to tmpdir when unsuccessful.
Diffstat (limited to 'spec/unit/provider/file/content_spec.rb')
-rw-r--r-- | spec/unit/provider/file/content_spec.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb index db0753bf8c..0a45d15bc9 100644 --- a/spec/unit/provider/file/content_spec.rb +++ b/spec/unit/provider/file/content_spec.rb @@ -70,12 +70,34 @@ describe Chef::Provider::File::Content do expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_falsey end - it "returns a tempfile in the destdir when :file_desployment_uses_destdir is not set" do + it "returns a tempfile in the destdir when :file_deployment_uses_destdir is set" do Chef::Config[:file_staging_uses_destdir] = true expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_falsey expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_truthy end + context "when creating a tempfiles in destdir fails" do + let(:enclosing_directory) { + canonicalize_path("/nonexisting/path") + } + + it "returns a tempfile in the tempdir when :file_deployment_uses_destdir is set to :auto" do + Chef::Config[:file_staging_uses_destdir] = :auto + expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_truthy + expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_falsey + end + + it "fails when :file_desployment_uses_destdir is set" do + Chef::Config[:file_staging_uses_destdir] = true + expect{content.tempfile}.to raise_error + end + + it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do + expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be_truthy + expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be_falsey + end + end + end describe "when the resource does not have a content attribute set" do @@ -90,4 +112,3 @@ describe Chef::Provider::File::Content do end end - |