diff options
author | Travis Fields <tfields@commercehub.com> | 2014-05-13 11:27:02 -0700 |
---|---|---|
committer | Travis Fields <tfields@commercehub.com> | 2014-05-13 13:17:14 -0700 |
commit | cfcd03a7c59eaa6b81de8c767bbd91e6d278c0f2 (patch) | |
tree | 9c12b98a82ea0666d9ba8b5925b51a7e547f1896 /spec/unit/puppet/provider/vcsrepo | |
parent | 46588aa62d444c5f0a538cccec357a80cd191b93 (diff) | |
download | puppet-vcsrepo-cfcd03a7c59eaa6b81de8c767bbd91e6d278c0f2.tar.gz puppet-vcsrepo-cfcd03a7c59eaa6b81de8c767bbd91e6d278c0f2.tar.bz2 |
Fix issue where force=>true was not destroying repository then recreating
Diffstat (limited to 'spec/unit/puppet/provider/vcsrepo')
-rw-r--r-- | spec/unit/puppet/provider/vcsrepo/git_spec.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb index ba726fa..ad6ed08 100644 --- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb +++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb @@ -9,6 +9,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do :revision => '2634', :source => 'git@repo', :path => '/tmp/test', + :force => false })} let(:provider) { resource.provider } @@ -151,12 +152,26 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do provider.expects(:convert_working_copy_to_bare) provider.create end + it "should clone overtop it using force" do + resource[:force] = true + Dir.expects(:chdir).with('/').at_least_once.yields + Dir.expects(:chdir).with('/tmp/test').at_least_once.yields + provider.expects(:path_exists?).returns(true) + provider.expects(:path_empty?).returns(false) + provider.destroy + provider.expects(:git).with('clone',resource.value(:source), resource.value(:path)) + provider.expects(:update_submodules) + provider.expects(:git).with('branch', '-a').returns(resource.value(:revision)) + provider.expects(:git).with('checkout', '--force', resource.value(:revision)) + provider.create + end end context "when the path is not empty and not a repository" do it "should raise an exception" do - expects_directory?(true) + provider.expects(:path_exists?).returns(true) provider.expects(:path_empty?).returns(false) + provider.expects(:working_copy_exists?).returns(false) proc { provider.create }.should raise_error(Puppet::Error) end end @@ -390,7 +405,7 @@ describe Puppet::Type.type(:vcsrepo).provider(:git_provider) do end end - describe 'convert_bare_to_working_copy' do + describe 'convert_bare_to_working_copy' do it do FileUtils.expects(:mv).returns(true) FileUtils.expects(:mkdir).returns(true) |