Debian Codegraph @

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

raw
1 test_name 'C3451 - checkout a revision (file path)'
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
19 teardown do
20 on(host, "rm -fr #{tmpdir}")
21 end
22
23 step 'get revision sha from repo' do
24 on(host, "git --git-dir=#{tmpdir}/testrepo.git rev-list HEAD | tail -1") do |res|
25 @sha = res.stdout.chomp
26 end
27 end
28
29 step 'checkout a revision with puppet' do
30 pp = <<-EOS
31 vcsrepo { "#{tmpdir}/#{repo_name}":
32 ensure => present,
33 source => "#{tmpdir}/testrepo.git",
34 provider => git,
35 revision => '#{@sha}',
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 repo is checked out to revision #{@sha}" 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('revision not found') unless res.stdout.include? "#{@sha}"
50 end
51 end
52
53 end