| 1 |
test_name 'C3482 - clone over an existing repo' |
| 2 |
|
| 3 |
# Globals |
| 4 |
repo_name = 'testrepo_already_exists' |
| 5 |
|
| 6 |
hosts.each do |host| |
| 7 |
tmpdir = host.tmpdir('vcsrepo') |
| 8 |
step 'setup - create repo' do |
| 9 |
git_pkg = 'git' |
| 10 |
if host['platform'] =~ /ubuntu-10/ |
| 11 |
git_pkg = 'git-core' |
| 12 |
end |
| 13 |
install_package(host, git_pkg) |
| 14 |
my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..')) |
| 15 |
scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir) |
| 16 |
on(host, "cd #{tmpdir} && ./create_git_repo.sh") |
| 17 |
on(host, "mkdir #{tmpdir}/#{repo_name}") |
| 18 |
on(host, "cd #{tmpdir}/#{repo_name} && git init") |
| 19 |
on(host, "cd #{tmpdir}/#{repo_name} && touch a && git add a && git commit -m 'a'") |
| 20 |
end |
| 21 |
|
| 22 |
teardown do |
| 23 |
on(host, "rm -fr #{tmpdir}") |
| 24 |
end |
| 25 |
|
| 26 |
step 'clone over existing repo using puppet' do |
| 27 |
on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| |
| 28 |
@existing_sha = res.stdout |
| 29 |
end |
| 30 |
pp = <<-EOS |
| 31 |
vcsrepo { "#{tmpdir}/#{repo_name}": |
| 32 |
ensure => present, |
| 33 |
source => "file://#{tmpdir}/testrepo.git", |
| 34 |
provider => git, |
| 35 |
} |
| 36 |
EOS |
| 37 |
|
| 38 |
apply_manifest_on(host, pp, :expect_failures => true) |
| 39 |
end |
| 40 |
|
| 41 |
step 'verify original repo was not replaced' do |
| 42 |
on(host, "cd #{tmpdir}/#{repo_name} && git log --pretty=format:\"%h\"") do |res| |
| 43 |
fail_test('original repo was replaced without force') unless res.stdout.include? "#{@existing_sha}" |
| 44 |
end |
| 45 |
end |
| 46 |
|
| 47 |
end |