summaryrefslogtreecommitdiff
path: root/spec/classes
diff options
context:
space:
mode:
authorGary Larizza <gary@puppetlabs.com>2012-05-09 16:38:43 -0700
committerGary Larizza <gary@puppetlabs.com>2012-05-09 16:38:43 -0700
commit580e831fbb7ba60cc0206661a8cfe263613c2b5e (patch)
tree5ea4f7ae5ef95e72433e046aed367cf07bfb9172 /spec/classes
parent01d46be262154b76ffd794fadf0d43deeb425fa6 (diff)
Commit spec tests for the haproxy module
Previously, the haproxy module didn't provide rspec tests for the class or defined resource types. This commit adds the tests, a spec_helper file, and a rakefile so you can do `rake spec` and automatically run the tests. I've also committed a symlink in the spec/fixtures/modules/haproxy directory so the rspec-puppet tests will FIND the haproxy class/defined resource types, but I HAVE NOT committed a symlink so that it will find the concat class (which is a dependency for this module). If you choose to run the tests, you must symlink the concat module in the spec/fixtures/modules directory before the spec tests will pass.
Diffstat (limited to 'spec/classes')
-rw-r--r--spec/classes/haproxy_spec.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/classes/haproxy_spec.rb b/spec/classes/haproxy_spec.rb
new file mode 100644
index 0000000..4c90b18
--- /dev/null
+++ b/spec/classes/haproxy_spec.rb
@@ -0,0 +1,61 @@
+require 'spec_helper'
+
+describe 'haproxy', :type => :class do
+
+ context 'on Redhat family operatingsystems' do
+ let(:facts) do
+ { :osfamily => 'Redhat' }
+ end
+ it { should include_class('concat::setup') }
+
+ it 'should install the haproxy package' do
+ subject.should contain_package('haproxy').with(
+ 'ensure' => 'present'
+ )
+ end
+
+ it 'should install the haproxy service' do
+ subject.should contain_service('haproxy').with(
+ 'ensure' => 'running',
+ 'enable' => 'true',
+ 'hasrestart' => 'true',
+ 'hasstatus' => 'true'
+ )
+ end
+
+ it 'should set up /etc/haproxy/haproxy.cfg as a concat resource' do
+ subject.should contain_concat('/etc/haproxy/haproxy.cfg').with(
+ 'owner' => '0',
+ 'group' => '0',
+ 'mode' => '0644'
+ )
+ end
+
+ it 'should contain a header concat fragment' do
+ subject.should contain_concat__fragment('00-header').with(
+ 'target' => '/etc/haproxy/haproxy.cfg',
+ 'order' => '01',
+ 'content' => "# This file managed by Puppet\n"
+ )
+ end
+
+ it 'should contain a haproxy-base concat fragment' do
+ subject.should contain_concat__fragment('haproxy-base').with(
+ 'target' => '/etc/haproxy/haproxy.cfg',
+ 'order' => '10',
+ 'content' => "global\n chroot /var/lib/haproxy\n daemon \n group haproxy\n log local0\n maxconn 4000\n pidfile /var/run/haproxy.pid\n stats socket /var/lib/haproxy/stats\n user haproxy\n\ndefaults\n log global\n maxconn 8000\n option redispatch\n retries 3\n stats enable\n timeout http-request 10s\n timeout queue 1m\n timeout connect 10s\n timeout client 1m\n timeout server 1m\n timeout check 10s\n"
+ )
+ end
+ end
+
+ context 'on non-Redhat family operatingsystems' do
+ let(:facts) do
+ { :osfamily => 'Debian' }
+ end
+ it do
+ expect {
+ should contain_service('haproxy')
+ }.to raise_error(Puppet::Error, /operating system is not supported with the haproxy module/)
+ end
+ end
+end \ No newline at end of file