Debian Codegraph @

spec/acceptance/beaker/git/revision_checkout/revision_checkout_git.rb

raw
1 test_name 'C3450 - checkout a revision (git protocol)'
2
3 # Globals
4 repo_name = 'testrepo_revision_checkout'
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 end
18 step 'setup - start git daemon' do
19 install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
20 on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
21 end
22
23 teardown do
24 on(host, "rm -fr #{tmpdir}")
25 on(host, 'pkill -9 git-daemon ; sleep 1')
26 end
27
28 step 'get revision sha from repo' do
29 on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
30 @sha = res.stdout.chomp
31 end
32 end
33
34 step 'checkout a revision with puppet' do
35 pp = <<-EOS
36 vcsrepo { "#{tmpdir}/#{repo_name}":
37 ensure => present,
38 source => "git://#{host}/testrepo.git",
39 provider => git,
40 revision => '#{@sha}',
41 }
42 EOS
43
44 apply_manifest_on(host, pp, :catch_failures => true)
45 apply_manifest_on(host, pp, :catch_changes => true)
46 end
47
48 step "verify checkout is set to revision #{@sha}" do
49 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
50 fail_test('checkout not found') unless res.stdout.include? "HEAD"
51 end
52
53 on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
54 fail_test('revision not found') unless res.stdout.include? "#{@sha}"
55 end
56 end
57
58 end