summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/acceptance/beaker/git/clone/negative/clone_over_different_exiting_repo.rb3
-rw-r--r--spec/acceptance/clone_repo_spec.rb17
-rw-r--r--spec/acceptance/modules_1596_spec.rb72
-rw-r--r--spec/unit/puppet/provider/vcsrepo/git_spec.rb57
4 files changed, 79 insertions, 70 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..2cca061 100644
--- a/spec/acceptance/clone_repo_spec.rb
+++ b/spec/acceptance/clone_repo_spec.rb
@@ -327,21 +327,18 @@ describe 'clones a remote repo' do
end
context 'and noop' do
- let(:repo_name) do
- 'testrepo_already_exists'
- end
before(:all) do
- shell("mkdir #{tmpdir}/#{repo_name}")
- shell("cd #{tmpdir}/#{repo_name} && git init")
- shell("cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'")
+ shell("mkdir #{tmpdir}/testrepo_already_exists")
+ shell("cd #{tmpdir}/testrepo_already_exists && git init")
+ shell("cd #{tmpdir}/testrepo_already_exists && touch a && git add a && git commit -m 'a'")
end
after(:all) do
- shell("rm -rf #{tmpdir}/#{repo_name}")
+ shell("rm -rf #{tmpdir}/testrepo_already_exists")
end
it 'applies the manifest' do
pp = <<-EOS
- vcsrepo { "#{tmpdir}/#{repo_name}":
+ vcsrepo { "#{tmpdir}/testrepo_already_exists":
ensure => present,
source => "file://#{tmpdir}/testrepo.git",
provider => git,
@@ -350,9 +347,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
diff --git a/spec/unit/puppet/provider/vcsrepo/git_spec.rb b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
index 122eb62..116e357 100644
--- a/spec/unit/puppet/provider/vcsrepo/git_spec.rb
+++ b/spec/unit/puppet/provider/vcsrepo/git_spec.rb
@@ -175,28 +175,6 @@ branches
provider.expects(:git).with('checkout', '--force', resource.value(:revision))
provider.create
end
- it "should warn about destroying it using force and noop attribute" do
- resource[:force] = true
- resource[:noop] = true
- resource.delete(:revision)
- provider.expects(:working_copy_exists?).returns(true)
-
- provider.expects(:destroy).never
- provider.expects(:create).never
- Puppet::Type::Vcsrepo::Ensure.any_instance.expects(:send_log).with(:notice, "Noop Mode - Would have deleted repository and re-created from latest")
- provider.resource.retrieve
- end
- it "should warn about destroying it using force and global noop" do
- resource[:force] = true
- Puppet[:noop] = true
- resource.delete(:revision)
- provider.expects(:working_copy_exists?).returns(true)
-
- provider.expects(:destroy).never
- provider.expects(:create).never
- Puppet::Type::Vcsrepo::Ensure.any_instance.expects(:send_log).with(:notice, "Noop Mode - Would have deleted repository and re-created from latest")
- provider.resource.retrieve
- end
end
context "when the path is not empty and not a repository" do
@@ -320,41 +298,6 @@ branches
end
end
- context "checking if revision" do
- before do
- expects_chdir
- provider.expects(:git).with('branch', '-a').returns(fixture(:git_branch_a))
- end
- context "is a local branch" do
- context "when it's listed in 'git branch -a'" do
- it "should return true" do
- resource[:revision] = 'feature/foo'
- expect(provider).to be_local_branch_revision
- end
- end
- context "when it's not listed in 'git branch -a'" do
- it "should return false" do
- resource[:revision] = 'feature/notexist'
- expect(provider).not_to be_local_branch_revision
- end
- end
- end
- context "is a remote branch" do
- context "when it's listed in 'git branch -a' with an 'origin/' prefix" do
- it "should return true" do
- resource[:revision] = 'only/remote'
- expect(provider).to be_remote_branch_revision
- end
- end
- context "when it's not listed in 'git branch -a' with an 'origin/' prefix" do
- it "should return false" do
- resource[:revision] = 'only/local'
- expect(provider).not_to be_remote_branch_revision
- end
- end
- end
- end
-
describe 'latest?' do
context 'when true' do
it do