1
0
mirror of https://github.com/krislamo/puppet-fluentd synced 2024-12-16 13:20:35 +00:00

added context to class spec tests to be able to test osfamily RedHat

This commit is contained in:
Max Wilhelm 2016-01-27 12:45:27 +01:00
parent be1a555591
commit ae7256a8c2
6 changed files with 141 additions and 58 deletions

View File

@ -1,16 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::config', :type => :class do describe 'fluentd::config', :type => :class do
let(:facts) { shared_examples 'when called with no parameters' do
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
describe 'when called with no parameters on Ubuntu' do
it { it {
should contain_file('/etc/td-agent/td-agent.conf').with({ should contain_file('/etc/td-agent/td-agent.conf').with({
'ensure' => 'file', 'ensure' => 'file',
@ -28,4 +19,27 @@ describe 'fluentd::config', :type => :class do
}) })
} }
end end
context 'when osfamily is Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
include_examples 'when called with no parameters'
end
context 'when osfamily is RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
include_examples 'when called with no parameters'
end
end end

View File

@ -1,16 +1,8 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::install', :type => :class do describe 'fluentd::install', :type => :class do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
describe 'when called with no parameters on Ubuntu' do shared_examples 'when called with no parameters' do
it { it {
should contain_package('fluentd').with({ should contain_package('fluentd').with({
'ensure' => 'installed', 'ensure' => 'installed',
@ -19,4 +11,27 @@ describe 'fluentd::install', :type => :class do
}) })
} }
end end
context 'when osfamily is Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
include_examples 'when called with no parameters'
end
context 'when osfamily is RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
include_examples 'when called with no parameters'
end
end end

View File

@ -1,6 +1,8 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::repo', :type => :class do describe 'fluentd::repo', :type => :class do
context 'when called with no parameters on osfamily Debian' do
let(:facts) { let(:facts) {
{ {
:osfamily => 'Debian', :osfamily => 'Debian',
@ -9,10 +11,19 @@ describe 'fluentd::repo', :type => :class do
:lsbdistcodename => 'precise', :lsbdistcodename => 'precise',
} }
} }
describe 'when called with no parameters on Ubuntu' do
it { it {
should contain_class('fluentd::repo::apt') should contain_class('fluentd::repo::apt')
} }
end end
context 'when called with no parameters on osfamily RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
it {
should contain_class('fluentd::repo::yum')
}
end
end end

View File

@ -1,16 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::config', :type => :class do describe 'fluentd::config', :type => :class do
let(:facts) { shared_examples 'when called with no parameters' do
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
describe 'when called with no parameters on Ubuntu' do
it { it {
should contain_service('fluentd').with({ should contain_service('fluentd').with({
'name' => 'td-agent', 'name' => 'td-agent',
@ -21,4 +12,27 @@ describe 'fluentd::config', :type => :class do
}) })
} }
end end
context 'when osfamily is Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
}
}
include_examples 'when called with no parameters'
end
context 'when osfamily is RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
include_examples 'when called with no parameters'
end
end end

View File

@ -1,6 +1,16 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd', :type => :class do describe 'fluentd', :type => :class do
shared_examples 'when called with no parameters' do
it {
should contain_class('fluentd::repo')
should contain_class('fluentd::install')
should contain_class('fluentd::config')
should contain_class('fluentd::service')
}
end
context 'when osfamily is Debian' do
let(:facts) { let(:facts) {
{ {
:osfamily => 'Debian', :osfamily => 'Debian',
@ -10,12 +20,17 @@ describe 'fluentd', :type => :class do
} }
} }
describe 'when called with no parameters on Ubuntu' do include_examples 'when called with no parameters'
it { end
should contain_class('fluentd::repo')
should contain_class('fluentd::install') context 'when osfamily is RedHat' do
should contain_class('fluentd::config') let(:facts) {
should contain_class('fluentd::service') {
:osfamily => 'RedHat',
} }
}
include_examples 'when called with no parameters'
end end
end end

View File

@ -1,6 +1,17 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::user', :type => :class do describe 'fluentd::user', :type => :class do
shared_examples 'when called with no parameters' do
it {
should contain_user('fluentd').with({
'name' => 'td-agent',
'gid' => 'td-agent',
'groups' => ['adm']
})
}
end
context 'when osfamily is Debian' do
let(:facts) { let(:facts) {
{ {
:osfamily => 'Debian', :osfamily => 'Debian',
@ -10,13 +21,16 @@ describe 'fluentd::user', :type => :class do
} }
} }
describe 'when called with no parameters on Ubuntu' do include_examples 'when called with no parameters'
it { end
should contain_user('fluentd').with({
'name' => 'td-agent', context 'when osfamily is RedHat' do
'gid' => 'td-agent', let(:facts) {
'groups' => ['adm'] {
}) :osfamily => 'RedHat',
} }
}
include_examples 'when called with no parameters'
end end
end end