Merge pull request #146 from daenney/mv-optional-commands
[puppet_vcsrepo.git] / spec / acceptance / beaker / git / branch_checkout / branch_checkout_file.rb
1 test_name 'C3438 - checkout a branch (file 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     install_package(host, 'git')
11     my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..'))
12     scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
13     on(host, "cd #{tmpdir} && ./create_git_repo.sh")
14   end
15
16   teardown do
17     on(host, "rm -fr #{tmpdir}")
18   end
19
20   step 'checkout a branch with puppet' do
21     pp = <<-EOS
22     vcsrepo { "#{tmpdir}/#{repo_name}":
23       ensure => present,
24       source => "file://#{tmpdir}/testrepo.git",
25       provider => git,
26       revision => '#{branch}',
27     }
28     EOS
29
30     apply_manifest_on(host, pp)
31     apply_manifest_on(host, pp)
32   end
33
34   step "verify checkout is on the #{branch} branch" do
35     on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
36       fail_test('checkout not found') unless res.stdout.include? "HEAD"
37     end
38
39     on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
40       fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/#{branch}"
41     end
42   end
43
44 end