summaryrefslogtreecommitdiff
path: root/spec/acceptance/create_repo_spec.rb
blob: db0cd295411406009a203eef9608e797b2a4242e (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
73
require 'spec_helper_acceptance'

tmpdir = default.tmpdir('vcsrepo')

describe 'create a repo' do
  context 'without a source' do
    it 'creates a blank repo' do
      pp = <<-EOS
      vcsrepo { "#{tmpdir}/testrepo_blank_repo":
        ensure => present,
        provider => git,
      }
      EOS

      # Run it twice and test for idempotency
      apply_manifest(pp, :catch_failures => true)
      apply_manifest(pp, :catch_changes => true)
    end

    describe file("#{tmpdir}/testrepo_blank_repo/") do
      it 'should have zero files' do
        shell("ls -1 #{tmpdir}/testrepo_blank_repo | wc -l") do |r|
          expect(r.stdout).to match(/^0\n$/)
        end
      end
    end

    describe file("#{tmpdir}/testrepo_blank_repo/.git") do
      it { is_expected.to be_directory }
    end
  end

  context 'bare repo' do
    it 'creates a bare repo' do
      pp = <<-EOS
      vcsrepo { "#{tmpdir}/testrepo_bare_repo":
        ensure => bare,
        provider => git,
      }
      EOS

      # Run it twice and test for idempotency
      apply_manifest(pp, :catch_failures => true)
      apply_manifest(pp, :catch_changes => true)
    end

    describe file("#{tmpdir}/testrepo_bare_repo/config") do
      it { is_expected.to contain 'bare = true' }
    end

    describe file("#{tmpdir}/testrepo_bare_repo/.git") do
      it { is_expected.not_to be_directory }
    end
  end

  context 'bare repo with a revision' do
    it 'does not create a bare repo when a revision is defined' do
      pp = <<-EOS
      vcsrepo { "#{tmpdir}/testrepo_bare_repo_rev":
        ensure => bare,
        provider => git,
        revision => 'master',
      }
      EOS

      apply_manifest(pp, :expect_failures => true)
    end

    describe file("#{tmpdir}/testrepo_bare_repo_rev") do
      it { is_expected.not_to be_directory }
    end
  end
end