Debian Codegraph @

spec/acceptance/beaker/git/branch_checkout/branch_checkout_git.rb

raw
1 test_name 'C3436 - checkout a branch (git protocol)'
2
3 # Globals
4 repo_name = 'testrepo_branch_checkout'
5 branch = 'a_branch'
6
7 hosts.each do |host|
8 tmpdir = host.tmpdir('vcsrepo')
9 step 'setup - create repo' do
10 git_pkg = 'git'
11 if host['platform'] =~ /ubuntu-10/
12 git_pkg = 'git-core'
13 end
14 install_package(host, git_pkg)
15 my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
16 scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
17 on(host, "cd #{tmpdir} && ./create_git_repo.sh")
18 end
19 step 'setup - start git daemon' do
20 install_package(host, 'git-daemon') unless host['platform'] =~ /debian|ubuntu/
21 on(host, "git daemon --base-path=#{tmpdir} --export-all --reuseaddr --verbose --detach")
22 end
23
24 teardown do
25 on(host, "rm -fr #{tmpdir}")
26 on(host, 'pkill -9 git-daemon ; sleep 1')
27 end
28
29 step 'checkout a branch with puppet' do
30 pp = <<-EOS
31 vcsrepo { "#{tmpdir}/#{repo_name}":
32 ensure => present,
33 source => "git://#{host}/testrepo.git",
34 provider => git,
35 revision => '#{branch}',
36 }
37 EOS
38
39 apply_manifest_on(host, pp, :catch_failures => true)
40 apply_manifest_on(host, pp, :catch_changes => true)
41 end
42
43 step "verify checkout is on the #{branch} branch" do
44 on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
45 fail_test('checkout not found') unless res.stdout.include? "HEAD"
46 end
47
48 on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
49 fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
50 end
51 end
52
53 end