newer pg module
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / spec / unit / classes / client_spec.rb
index 6da32b3..3f2e58f 100644 (file)
@@ -3,9 +3,56 @@ require 'spec_helper'
 describe 'postgresql::client', :type => :class do
   let :facts do
     {
-      :postgres_default_version => '8.4',
       :osfamily => 'Debian',
+      :operatingsystem => 'Debian',
+      :operatingsystemrelease => '6.0',
     }
   end
-  it { should include_class("postgresql::client") }
+
+  describe 'with parameters' do
+    let :params do
+      {
+        :validcon_script_path  => '/opt/bin/my-validate-con.sh',
+        :package_ensure => 'absent',
+        :package_name   => 'mypackage',
+        :file_ensure    => 'file'
+      }
+    end
+
+    it 'should modify package' do
+      is_expected.to contain_package("postgresql-client").with({
+        :ensure => 'absent',
+        :name => 'mypackage',
+        :tag => 'postgresql',
+      })
+    end
+
+    it 'should have specified validate connexion' do
+      should contain_file('/opt/bin/my-validate-con.sh').with({
+        :ensure => 'file',
+        :owner  => 0,
+        :group  => 0,
+        :mode   => '0755'
+      })
+    end
+  end
+
+  describe 'with no parameters' do
+    it 'should create package with postgresql tag' do
+      is_expected.to contain_package('postgresql-client').with({
+        :tag => 'postgresql',
+      })
+    end
+  end
+
+  describe 'with client package name explicitly set undef' do
+    let :params do
+      {
+        :package_name => 'UNSET'
+      }
+    end
+    it 'should not manage postgresql-client package' do
+      is_expected.not_to contain_package('postgresql-client')
+    end
+  end
 end