Merge pull request #230 from jonnytpuppet/multiple_remotes
[puppet_vcsrepo.git] / spec / acceptance / modules_753_spec.rb
1 require 'spec_helper_acceptance'
2
3 tmpdir = default.tmpdir('vcsrepo')
4
5 describe 'clones a remote repo' do
6   before(:all) do
7     my_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
8     shell("mkdir -p #{tmpdir}") # win test
9   end
10
11   after(:all) do
12     shell("rm -rf #{tmpdir}/vcsrepo")
13   end
14
15   context 'clone with single remote' do
16     it 'clones from default remote' do
17       pp = <<-EOS
18       vcsrepo { "#{tmpdir}/vcsrepo":
19           ensure   => present,
20           provider => git,
21           source   => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git",
22       }
23       EOS
24
25       apply_manifest(pp, :catch_failures => true)
26
27     end
28
29     it "git config output should contain the remote" do
30       shell("/usr/bin/git config -l -f #{tmpdir}/vcsrepo/.git/config") do |r|
31         expect(r.stdout).to match(/remote.origin.url=https:\/\/github.com\/puppetlabs\/puppetlabs-vcsrepo.git/)
32       end
33     end
34
35     after(:all) do
36       shell("rm -rf #{tmpdir}/vcsrepo")
37     end
38
39   end
40
41   context 'clone with multiple remotes' do
42     it 'clones from default remote and adds 2 remotes to config file' do
43       pp = <<-EOS
44       vcsrepo { "#{tmpdir}/vcsrepo":
45           ensure   => present,
46           provider => git,
47           source   => {"origin" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git", "test1" => "https://github.com/puppetlabs/puppetlabs-vcsrepo.git"},
48       }
49       EOS
50
51       apply_manifest(pp, :catch_failures => true)
52
53     end
54
55     it "git config output should contain the remotes" do
56       shell("/usr/bin/git config -l -f #{tmpdir}/vcsrepo/.git/config") do |r|
57         expect(r.stdout).to match(/remote.origin.url=https:\/\/github.com\/puppetlabs\/puppetlabs-vcsrepo.git/)
58         expect(r.stdout).to match(/remote.test1.url=https:\/\/github.com\/puppetlabs\/puppetlabs-vcsrepo.git/)
59       end
60     end
61
62     after(:all) do
63       shell("rm -rf #{tmpdir}/vcsrepo")
64     end
65
66   end
67
68 end