Merge pull request #146 from daenney/mv-optional-commands
[puppet_vcsrepo.git] / spec / acceptance / beaker / git / branch_checkout / negative / branch_checkout_not_exists.rb
1 test_name 'C3609 - checkout a branch that does not exist'
2
3 # Globals
4 repo_name = 'testrepo_branch_checkout'
5
6 hosts.each do |host|
7   tmpdir = host.tmpdir('vcsrepo')
8   step 'setup - create repo' do
9     install_package(host, 'git')
10     my_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../../..'))
11     scp_to(host, "#{my_root}/acceptance/files/create_git_repo.sh", tmpdir)
12     on(host, "cd #{tmpdir} && ./create_git_repo.sh")
13   end
14
15   teardown do
16     on(host, "rm -fr #{tmpdir}")
17   end
18
19   step 'checkout branch that does not exist with puppet' do
20     pp = <<-EOS
21     vcsrepo { "#{tmpdir}/#{repo_name}":
22       ensure => present,
23       source => "file://#{tmpdir}/testrepo.git",
24       provider => git,
25       revision => 'non_existent_branch',
26     }
27     EOS
28
29     apply_manifest_on(host, pp)
30     apply_manifest_on(host, pp)
31   end
32
33   step 'verify that master branch is checked out' do
34     on(host, "ls #{tmpdir}/#{repo_name}/.git/") do |res|
35       fail_test('checkout not found') unless res.stdout.include? "HEAD"
36     end
37
38     on(host, "cat #{tmpdir}/#{repo_name}/.git/HEAD") do |res|
39       fail_test('branch not found') unless res.stdout.include? "ref: refs/heads/master"
40     end
41   end
42
43 end