From 0479c58b7ced2d9bbf416acba8091543874b9c96 Mon Sep 17 00:00:00 2001 From: Aimon Bustardo Date: Tue, 7 Jul 2015 12:02:33 -0700 Subject: [PATCH] Add missing bind tools package and improve rspec tests Change-Id: I0b4680ce11fe604917fce654d68c2bec17c05438 --- manifests/init.pp | 6 ++++ spec/classes/bind_spec.rb | 73 +++++++++++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 25e21d7d..eeefa7ec 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -24,6 +24,12 @@ notify => Service['bind'], } + package{'bind-tools': + ensure => latest, + name => $::bind::params::nsupdate_package, + before => Package['bind'], + } + package { 'bind': ensure => latest, name => $::bind::params::bind_package, diff --git a/spec/classes/bind_spec.rb b/spec/classes/bind_spec.rb index 20568b7c..6b24cb5f 100644 --- a/spec/classes/bind_spec.rb +++ b/spec/classes/bind_spec.rb @@ -2,23 +2,66 @@ require 'spec_helper' describe 'bind' do - let(:facts) { { :concat_basedir => '/wtf' } } + context "on a Debian OS" do + let :facts do + { + :concat_basedir => '/wtf', + :osfamily => 'Debian', + :operatingsystem => 'Debian' + } + end + it { + should contain_package('bind-tools').with({ + 'ensure' => 'latest', + 'name' => 'dnsutils' + }).that_comes_before('Package[bind]') + } + it { + should contain_package('bind').with({ + 'ensure' => 'latest', + 'name' => 'bind9' + }) + } - it { - should contain_package('bind').with({ - 'ensure' => 'latest', - 'name' => 'bind9' - }) - } + it { should contain_file('_NAMEDCONF_').that_requires('Package[bind]') } + it { should contain_file('_NAMEDCONF_').that_notifies('Service[bind]') } - it { should contain_file('_NAMEDCONF_').that_requires('Package[bind]') } - it { should contain_file('_NAMEDCONF_').that_notifies('Service[bind]') } + it { + should contain_service('bind').with({ + 'ensure' => 'running', + 'name' => 'bind9' + }) + } + end + context "on a RedHat OS" do + let :facts do + { + :concat_basedir => '/wtf', + :osfamily => 'RedHat', + :operatingsystem => 'CentOS' + } + end + it { + should contain_package('bind-tools').with({ + 'ensure' => 'latest', + 'name' => 'bind-utils' + }) + } + it { + should contain_package('bind').with({ + 'ensure' => 'latest', + 'name' => 'bind' + }) + } - it { - should contain_service('bind').with({ - 'ensure' => 'running', - 'name' => 'bind9' - }) - } + it { should contain_file('_NAMEDCONF_').that_requires('Package[bind]') } + it { should contain_file('_NAMEDCONF_').that_notifies('Service[bind]') } + it { + should contain_service('bind').with({ + 'ensure' => 'running', + 'name' => 'named' + }) + } + end end