Skip to content

Commit

Permalink
fix spec errors in jenkins_repo_spec.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jun 22, 2018
1 parent 4d201f8 commit b5400e9
Showing 1 changed file with 40 additions and 62 deletions.
102 changes: 40 additions & 62 deletions spec/classes/jenkins_repo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,72 +1,50 @@
require 'spec_helper'

describe 'jenkins', type: :class do
describe 'repo' do
describe 'default' do
describe 'RedHat' do
let(:facts) do
{
osfamily: 'RedHat',
operatingsystem: 'CentOs',
operatingsystemrelease: '6.7',
operatingsystemmajrelease: '6'
}
end

it { is_expected.to contain_class('jenkins::repo::el') }
it { is_expected.not_to contain_class('jenkins::repo::suse') }
it { is_expected.not_to contain_class('jenkins::repo::debian') }
on_supported_os.each do |os, facts|
context "on #{os} " do
systemd_fact = case facts[:operatingsystemmajrelease]
when '6'
{ systemd: false }
else
{ systemd: true }
end
let :facts do
facts.merge(systemd_fact)
end

describe 'Suse' do
let(:facts) { { osfamily: 'Suse', operatingsystem: 'OpenSuSE' } }

it { is_expected.to contain_class('jenkins::repo::suse') }
it { is_expected.not_to contain_class('jenkins::repo::el') }
it { is_expected.not_to contain_class('jenkins::repo::debian') }
end

describe 'Debian' do
let(:facts) do
{
osfamily: 'Debian',
lsbdistid: 'debian',
lsbdistcodename: 'natty',
operatingsystem: 'Debian',
os: {
name: 'Debian',
release: { full: '11.04' }
}
}
describe 'repo' do
describe 'default' do
case facts[:os]['family']
when 'RedHat'
describe 'RedHat' do
it { is_expected.to contain_class('jenkins::repo::el') }
it { is_expected.not_to contain_class('jenkins::repo::suse') }
it { is_expected.not_to contain_class('jenkins::repo::debian') }
end
describe 'repo => false' do
let(:params) { { repo: false } }

it { is_expected.not_to contain_class('jenkins::repo') }
it { is_expected.not_to contain_class('jenkins::repo::el') }
it { is_expected.not_to contain_class('jenkins::repo::suse') }
it { is_expected.not_to contain_class('jenkins::repo::debian') }
end
when 'Suse'
describe 'Suse' do
it { is_expected.to contain_class('jenkins::repo::suse') }
it { is_expected.not_to contain_class('jenkins::repo::el') }
it { is_expected.not_to contain_class('jenkins::repo::debian') }
end
when 'Debian'
describe 'Debian' do
it { is_expected.to contain_class('jenkins::repo::debian') }
it { is_expected.not_to contain_class('jenkins::repo::suse') }
it { is_expected.not_to contain_class('jenkins::repo::el') }
end
end
end

it { is_expected.to contain_class('jenkins::repo::debian') }
it { is_expected.not_to contain_class('jenkins::repo::suse') }
it { is_expected.not_to contain_class('jenkins::repo::el') }
end

describe 'Unknown' do
let(:facts) { { osfamily: 'SomethingElse', operatingsystem: 'RedHat' } }

it { expect { is_expected.to raise_error(Puppet::Error) } }
end
end

describe 'repo => false' do
let(:facts) do
{
osfamily: 'RedHat',
operatingsystem: 'CentOs',
operatingsystemrelease: '6.7',
operatingsystemmajrelease: '6'
}
end
let(:params) { { repo: false } }

it { is_expected.not_to contain_class('jenkins::repo') }
it { is_expected.not_to contain_class('jenkins::repo::el') }
it { is_expected.not_to contain_class('jenkins::repo::suse') }
it { is_expected.not_to contain_class('jenkins::repo::debian') }
end
end
end

0 comments on commit b5400e9

Please sign in to comment.