Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix creating droplets directory if it was defined

Change-Id: Ia38a53ad034a1a25705660da6d28fdaefb5066c1
  • Loading branch information...
commit 1082742f955873882d79aaa081da785388807a9b 1 parent 7f51a66
@mariash mariash authored
Showing with 38 additions and 1 deletion.
  1. +3 −1 lib/cloud_controller/app_package.rb
  2. +35 −0 spec/app_package_spec.rb
View
4 lib/cloud_controller/app_package.rb
@@ -45,7 +45,9 @@ def delete_package(guid)
#
# Makes the directory on first use.
def package_dir
- unless @config[:directories] && @config[:directories][:droplets]
+ if @config[:directories] && @config[:directories][:droplets]
+ FileUtils.mkdir_p(@config[:directories][:droplets])
+ else
# TODO: remove this tmpdir. It is for use when running under vcap
# for development
@config[:directories] ||= {}
View
35 spec/app_package_spec.rb
@@ -177,4 +177,39 @@ module VCAP::CloudController
end
end
end
+
+ describe "#package_dir" do
+ subject { AppPackage.package_dir }
+ let(:config) { { :directories => { :droplets => "/from_config" } } }
+ before { AppPackage.configure(config) }
+
+ context "when droplets directory was defined in configuration" do
+ it "creates defined droplets directory" do
+ FileUtils.should_receive(:mkdir_p).with("/from_config")
+ subject
+ end
+ end
+
+ shared_examples "creating and setting droplets directory" do
+ it "creates temporary droplets directory" do
+ Dir.should_receive(:mktmpdir)
+ subject
+ end
+
+ it "sets temporary droplets directory in configuration" do
+ Dir.should_receive(:mktmpdir) { "/temporary_dir" }
+ subject.should eq "/temporary_dir"
+ end
+ end
+
+ context "when directories were not defined in configuration" do
+ let(:config) { {} }
+ include_examples "creating and setting droplets directory"
+ end
+
+ context "when droplets directory was not defined in configuration" do
+ let(:config) { { :directories => { } } }
+ include_examples "creating and setting droplets directory"
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.