diff options
author | John Goulah <jgoulah@gmail.com> | 2013-02-03 16:30:26 -0500 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2013-11-26 07:31:19 -0800 |
commit | c7f2c834ae4f57245831bd537843646015943c03 (patch) | |
tree | a557acd5892bdf77dbc319dc8ffdc7bcae1ba6d7 /spec | |
parent | 9621c3b58c766dffdaadf7ae5436b530cc9d5bbe (diff) | |
download | chef-c7f2c834ae4f57245831bd537843646015943c03.tar.gz |
some tests for the enable_checkout option
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/git_spec.rb | 15 | ||||
-rw-r--r-- | spec/unit/resource/scm_spec.rb | 10 |
2 files changed, 25 insertions, 0 deletions
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index 2bf55930db..31fb6e38ef 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -402,6 +402,21 @@ SHAS # @resource.should be_updated end + it "does not call checkout if enable_checkout is false" do + # will be invoked in load_current_resource + ::File.stub!(:exist?).with("/my/deploy/dir/.git").and_return(false) + + ::File.stub!(:exist?).with("/my/deploy/dir").and_return(true) + ::File.stub!(:directory?).with("/my/deploy").and_return(true) + ::Dir.stub!(:entries).with("/my/deploy/dir").and_return(['.','..']) + + @resource.enable_checkout false + @provider.should_receive(:clone) + @provider.should_not_receive(:checkout) + @provider.should_receive(:enable_submodules) + @provider.run_action(:checkout) + end + # REGRESSION TEST: on some OSes, the entries from an empty directory will be listed as # ['..', '.'] but this shouldn't change the behavior it "does a checkout by cloning the repo and then enabling submodules when the directory entries are listed as %w{.. .}" do diff --git a/spec/unit/resource/scm_spec.rb b/spec/unit/resource/scm_spec.rb index 8f6593a931..2141ae3c88 100644 --- a/spec/unit/resource/scm_spec.rb +++ b/spec/unit/resource/scm_spec.rb @@ -118,6 +118,16 @@ describe Chef::Resource::Scm do @resource.enable_submodules.should be_false end + it "takes a boolean for #enable_checkout" do + @resource.enable_checkout true + @resource.enable_checkout.should be_true + lambda {@resource.enable_checkout "lolz"}.should raise_error(ArgumentError) + end + + it "defaults to enabling checkout" do + @resource.enable_checkout.should be_true + end + it "takes a string for the remote" do @resource.remote "opscode" @resource.remote.should eql("opscode") |