summaryrefslogtreecommitdiff
path: root/spec/acceptance/modules_1596_spec.rb
blob: fa36285a17308805fb84534de8566ed3808c7e0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'spec_helper_acceptance'

tmpdir = default.tmpdir('vcsrepo')

describe 'clones a remote repo' do
  before(:all) do
    my_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
    shell("mkdir -p #{tmpdir}") # win test
  end

  after(:all) do
    shell("rm -rf #{tmpdir}/vcsrepo")
  end

  context 'force with a remote' do
    it 'clones from remote' do
      pp = <<-EOS
      vcsrepo { "#{tmpdir}/vcsrepo":
        ensure   => present,
        provider => git,
        source   => 'https://github.com/puppetlabs/puppetlabs-vcsrepo',
        force    => true,
      }
      EOS

      # Run it twice to test for idempotency
      apply_manifest(pp, :catch_failures => true)
      # need to create a file to make sure we aren't destroying the repo
      # because fun fact, if you call destroy/create in 'retrieve' puppet won't
      # register that any changes happen, because that method isn't supposed to
      # be making any changes.
      shell("touch #{tmpdir}/vcsrepo/foo")
      apply_manifest(pp, :catch_changes  => true)
    end

    describe file("#{tmpdir}/vcsrepo/foo") do
      it { is_expected.to be_file }
    end
  end

  context 'force over an existing repo' do
    it 'clones from remote' do
      pp = <<-EOS
      vcsrepo { "#{tmpdir}/vcsrepo":
        ensure   => present,
        provider => git,
        source   => 'https://github.com/puppetlabs/puppetlabs-vcsrepo',
        force    => true,
      }
      EOS

      pp2 = <<-EOS
      vcsrepo { "#{tmpdir}/vcsrepo":
        ensure   => present,
        provider => git,
        source   => 'https://github.com/puppetlabs/puppetlabs-stdlib',
        force    => true,
      }
      EOS


      apply_manifest(pp, :catch_failures => true)
      # create a file to make sure we're destroying the repo
      shell("touch #{tmpdir}/vcsrepo/foo")
      apply_manifest(pp2, :catch_failures  => true)
    end

    describe file("#{tmpdir}/vcsrepo/foo") do
      it { is_expected.to_not be_file }
    end
  end
end