diff options
author | John Duarte <john.duarte@puppetlabs.com> | 2014-05-10 09:36:26 -0700 |
---|---|---|
committer | John Duarte <john.duarte@puppetlabs.com> | 2014-05-18 11:38:19 -0700 |
commit | 35fd8b137fa83d34eb90df400ccd1da78a947b18 (patch) | |
tree | cd7ccc58015dadb5d94bc9f0158aa8d6868e7571 /spec/acceptance/beaker | |
parent | 60d5e83205a38f714ae678142e14a0d223076028 (diff) | |
download | puppet-vcsrepo-35fd8b137fa83d34eb90df400ccd1da78a947b18.tar.gz puppet-vcsrepo-35fd8b137fa83d34eb90df400ccd1da78a947b18.tar.bz2 |
Add beaker tests for git create
Diffstat (limited to 'spec/acceptance/beaker')
3 files changed, 106 insertions, 0 deletions
diff --git a/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb b/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb new file mode 100644 index 0000000..663c758 --- /dev/null +++ b/spec/acceptance/beaker/create/create_bare_repo_that_already_exists.rb @@ -0,0 +1,35 @@ +test_name 'C3472 - create bare repo that already exists' + +# Globals +repo_name = 'testrepo_bare_repo_already_exists.git' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create bare repo' do + install_package(host, 'git') + on(host, "mkdir #{tmpdir}/#{repo_name}") + on(host, "cd #{tmpdir}/#{repo_name} && git --bare init") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'create bare repo that already exists using puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => bare, + provider => git, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify repo does not contain .git directory' do + on(host, "ls -al #{tmpdir}/#{repo_name}") do |res| + fail_test "found .git for #{repo_name}" if res.stdout.include? ".git" + end + end + +end diff --git a/spec/acceptance/beaker/create/create_repo_that_already_exists.rb b/spec/acceptance/beaker/create/create_repo_that_already_exists.rb new file mode 100644 index 0000000..7c28998 --- /dev/null +++ b/spec/acceptance/beaker/create/create_repo_that_already_exists.rb @@ -0,0 +1,37 @@ +test_name 'C3470 - create repo that already exists' + +# Globals +repo_name = 'testrepo_already_exists' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup - create repo' do + install_package(host, 'git') + my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../..')) + scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) + on(host, "cd #{tmpdir} && ./create_git_repo.sh") + on(host, "cd #{tmpdir} && git clone file://#{tmpdir}/testrepo.git #{repo_name}") + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'create repo that already exists using puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => present, + provider => git, + } + EOS + + apply_manifest_on(host, pp) + end + + step 'verify repo is on master branch' do + on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res| + assert_match(/ref: refs\/heads\/master/, stdout, "Git checkout not on master on #{host}") + end + end + +end diff --git a/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb b/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb new file mode 100644 index 0000000..6a12c8c --- /dev/null +++ b/spec/acceptance/beaker/create/negative/create_bare_repo_specifying_revision.rb @@ -0,0 +1,34 @@ +test_name 'C3473 - create bare repo specifying revision' + +# Globals +repo_name = 'testrepo_bare.git' + +hosts.each do |host| + tmpdir = host.tmpdir('vcsrepo') + step 'setup' do + install_package(host, 'git') + end + + teardown do + on(host, "rm -fr #{tmpdir}") + end + + step 'create bare repo specifying revision using puppet' do + pp = <<-EOS + vcsrepo { "#{tmpdir}/#{repo_name}": + ensure => bare, + revision => master, + provider => git, + } + EOS + + apply_manifest_on(host, pp, :acceptable_exit_codes => [1]) + end + + step 'verify repo was NOT created' do + on(host, "ls -al #{tmpdir}") do |res| + fail_test "found #{repo_name}" if res.stdout.include? "#{repo_name}" + end + end + +end |