clone_spec.rb 3.64 KB
Newer Older
Marin Jankovski's avatar
Marin Jankovski committed
1 2 3
require 'spec_helper'

describe "gitlab::clone" do
Marin Jankovski's avatar
Marin Jankovski committed
4
  let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::clone", "gitlab::start") }
Marin Jankovski's avatar
Marin Jankovski committed
5 6 7 8


  describe "under ubuntu" do
    ["12.04", "10.04"].each do |version|
9
      let(:chef_run) do
Marin Jankovski's avatar
Marin Jankovski committed
10 11
        runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
        runner.node.set['gitlab']['env'] = "production"
Marin Jankovski's avatar
Marin Jankovski committed
12
        runner.converge("gitlab::clone", "gitlab::start")
Marin Jankovski's avatar
Marin Jankovski committed
13 14 15 16 17
      end

      it "clones the gitlab repository" do
        expect(chef_run).to sync_git('/home/git/gitlab').with(
          repository: 'https://github.com/gitlabhq/gitlabhq.git',
Marin Jankovski's avatar
Marin Jankovski committed
18
          revision: '7-2-stable',
Marin Jankovski's avatar
Marin Jankovski committed
19 20 21 22 23 24
          user: 'git',
          group: 'git'
        )
      end

      describe "in development" do
25
        let(:chef_run) do
Marin Jankovski's avatar
Marin Jankovski committed
26 27
          runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
          runner.node.set['gitlab']['env'] = "development"
Marin Jankovski's avatar
Marin Jankovski committed
28
          runner.converge("gitlab::clone", "gitlab::start")
Marin Jankovski's avatar
Marin Jankovski committed
29 30 31
        end

        it "clones the gitlab repository" do
32
          expect(chef_run).to sync_git('/home/git/gitlab').with(
Marin Jankovski's avatar
Marin Jankovski committed
33 34
            repository: 'https://github.com/gitlabhq/gitlabhq.git',
            revision: 'master',
35 36
            user: 'git',
            group: 'git'
Marin Jankovski's avatar
Marin Jankovski committed
37 38 39
          )
        end
      end
40 41 42 43 44 45 46 47 48 49 50 51

      describe "when customizing gitlab user home" do
        let(:chef_run) do
          runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
          runner.node.set['gitlab']['env'] = "production"
          runner.node.set['gitlab']['home'] = "/data/git"
          runner.converge("gitlab::clone", "gitlab::start")
        end

        it "clones the gitlab repository" do
          expect(chef_run).to sync_git('/data/git/gitlab').with(
            repository: 'https://github.com/gitlabhq/gitlabhq.git',
Marin Jankovski's avatar
Marin Jankovski committed
52
            revision: '7-2-stable',
53 54 55 56 57
            user: 'git',
            group: 'git'
          )
        end
      end
Marin Jankovski's avatar
Marin Jankovski committed
58 59 60 61 62
    end
  end

  describe "under centos" do
    ["5.8", "6.4"].each do |version|
63
      let(:chef_run) do
Marin Jankovski's avatar
Marin Jankovski committed
64 65
        runner = ChefSpec::Runner.new(platform: "centos", version: version)
        runner.node.set['gitlab']['env'] = "production"
Marin Jankovski's avatar
Marin Jankovski committed
66
        runner.converge("gitlab::clone", "gitlab::start")
Marin Jankovski's avatar
Marin Jankovski committed
67 68 69 70 71
      end

      it "clones the gitlab repository" do
        expect(chef_run).to sync_git('/home/git/gitlab').with(
          repository: 'https://github.com/gitlabhq/gitlabhq.git',
Marin Jankovski's avatar
Marin Jankovski committed
72
          revision: '7-2-stable',
Marin Jankovski's avatar
Marin Jankovski committed
73 74 75 76 77 78
          user: 'git',
          group: 'git'
        )
      end

      describe "in development" do
79
        let(:chef_run) do
Marin Jankovski's avatar
Marin Jankovski committed
80 81
          runner = ChefSpec::Runner.new(platform: "centos", version: version)
          runner.node.set['gitlab']['env'] = "development"
Marin Jankovski's avatar
Marin Jankovski committed
82
          runner.converge("gitlab::clone", "gitlab::start")
Marin Jankovski's avatar
Marin Jankovski committed
83 84 85
        end

        it "clones the gitlab repository" do
86
          expect(chef_run).to sync_git('/home/git/gitlab').with(
Marin Jankovski's avatar
Marin Jankovski committed
87 88
            repository: 'https://github.com/gitlabhq/gitlabhq.git',
            revision: 'master',
89 90
            user: 'git',
            group: 'git'
Marin Jankovski's avatar
Marin Jankovski committed
91 92 93
          )
        end
      end
94 95 96 97 98 99 100 101 102 103 104 105

      describe "when customizing gitlab user home" do
        let(:chef_run) do
          runner = ChefSpec::Runner.new(platform: "centos", version: version)
          runner.node.set['gitlab']['env'] = "production"
          runner.node.set['gitlab']['home'] = "/data/git"
          runner.converge("gitlab::clone", "gitlab::start")
        end

        it "clones the gitlab repository" do
          expect(chef_run).to sync_git('/data/git/gitlab').with(
            repository: 'https://github.com/gitlabhq/gitlabhq.git',
Marin Jankovski's avatar
Marin Jankovski committed
106
            revision: '7-2-stable',
107 108 109 110 111
            user: 'git',
            group: 'git'
          )
        end
      end
Marin Jankovski's avatar
Marin Jankovski committed
112 113
    end
  end
114
end