diff options
author | Morgan Haskel <morgan@puppetlabs.com> | 2014-12-26 15:27:20 -0800 |
---|---|---|
committer | Morgan Haskel <morgan@puppetlabs.com> | 2014-12-26 15:49:52 -0800 |
commit | 56f25d57dfa26de618416e9bdd4a853296ffcbc1 (patch) | |
tree | 46a6c7e81c71f6b91e547cc49099da503658a6f3 /spec/acceptance | |
parent | 2295710e094ef849052e4b785819a1ba3a2c0fc6 (diff) | |
download | puppet-vcsrepo-56f25d57dfa26de618416e9bdd4a853296ffcbc1.tar.gz puppet-vcsrepo-56f25d57dfa26de618416e9bdd4a853296ffcbc1.tar.bz2 |
MODULES-1596 - Repository repeatedly destroyed/created with force
The `retrieve` method was calling `create` and `destroy` on every run
with `force => true`. Retrieve should not be making any changes to the
system, so removed that code, and updated `working_copy_exists` to make
sure that the directory not only contains a `.git` directory, but also
if `source` is specified it also matches `#{path}/.git/config` so that
it will overwrite a git repo with a different source.
Updated tests to not check for the old broken behavior. Added a regression test.
Diffstat (limited to 'spec/acceptance')
-rw-r--r-- | spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb | 3 | ||||
-rw-r--r-- | spec/acceptance/clone_repo_spec.rb | 4 | ||||
-rw-r--r-- | spec/acceptance/modules_1596_spec.rb | 72 |
3 files changed, 74 insertions, 5 deletions
diff --git a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb index 6826673..1e3b4bb 100644 --- a/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb +++ b/spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb @@ -35,8 +35,7 @@ hosts.each do |host| } EOS - apply_manifest_on(host, pp, :catch_failures => true) - apply_manifest_on(host, pp, :catch_changes => true) + apply_manifest_on(host, pp, :expect_failures => true) end step 'verify original repo was not replaced' do diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index f3e77db..4e9293b 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -350,9 +350,7 @@ describe 'clones a remote repo' do } EOS - apply_manifest(pp, :catch_changes => true) do |r| - expect(r.stdout).to match(/Noop Mode/) - end + apply_manifest(pp, :catch_changes => true) end end end diff --git a/spec/acceptance/modules_1596_spec.rb b/spec/acceptance/modules_1596_spec.rb new file mode 100644 index 0000000..fa36285 --- /dev/null +++ b/spec/acceptance/modules_1596_spec.rb @@ -0,0 +1,72 @@ +require 'spec_helper_acceptance' + +tmpdir = default.tmpdir('vcsrepo') + +describe 'clones a remote repo' do + before(:all) do + my_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + shell("mkdir -p #{tmpdir}") # win test + end + + after(:all) do + shell("rm -rf #{tmpdir}/vcsrepo") + end + + context 'force with a remote' do + it 'clones from remote' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => 'https://github.com/puppetlabs/puppetlabs-vcsrepo', + force => true, + } + EOS + + # Run it twice to test for idempotency + apply_manifest(pp, :catch_failures => true) + # need to create a file to make sure we aren't destroying the repo + # because fun fact, if you call destroy/create in 'retrieve' puppet won't + # register that any changes happen, because that method isn't supposed to + # be making any changes. + shell("touch #{tmpdir}/vcsrepo/foo") + apply_manifest(pp, :catch_changes => true) + end + + describe file("#{tmpdir}/vcsrepo/foo") do + it { is_expected.to be_file } + end + end + + context 'force over an existing repo' do + it 'clones from remote' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => 'https://github.com/puppetlabs/puppetlabs-vcsrepo', + force => true, + } + EOS + + pp2 = <<-EOS + vcsrepo { "#{tmpdir}/vcsrepo": + ensure => present, + provider => git, + source => 'https://github.com/puppetlabs/puppetlabs-stdlib', + force => true, + } + EOS + + + apply_manifest(pp, :catch_failures => true) + # create a file to make sure we're destroying the repo + shell("touch #{tmpdir}/vcsrepo/foo") + apply_manifest(pp2, :catch_failures => true) + end + + describe file("#{tmpdir}/vcsrepo/foo") do + it { is_expected.to_not be_file } + end + end +end |