config_spec.rb 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. require 'spec_helper'
  2. describe 'postgresql::server::config', :type => :class do
  3. let (:pre_condition) do
  4. "include postgresql::server"
  5. end
  6. describe 'on RedHat 7' do
  7. let :facts do
  8. {
  9. :osfamily => 'RedHat',
  10. :operatingsystem => 'CentOS',
  11. :operatingsystemrelease => '7.0',
  12. :concat_basedir => tmpfilename('server'),
  13. :kernel => 'Linux',
  14. :id => 'root',
  15. :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
  16. }
  17. end
  18. it 'should have the correct systemd-override file' do
  19. is_expected.to contain_file('systemd-override').with ({
  20. :ensure => 'present',
  21. :path => '/etc/systemd/system/postgresql.service',
  22. :owner => 'root',
  23. :group => 'root',
  24. })
  25. is_expected.to contain_file('systemd-override') \
  26. .with_content(/.include \/usr\/lib\/systemd\/system\/postgresql.service/)
  27. end
  28. describe 'with manage_package_repo => true and a version' do
  29. let (:pre_condition) do
  30. <<-EOS
  31. class { 'postgresql::globals':
  32. manage_package_repo => true,
  33. version => '9.4',
  34. }->
  35. class { 'postgresql::server': }
  36. EOS
  37. end
  38. it 'should have the correct systemd-override file' do
  39. is_expected.to contain_file('systemd-override').with ({
  40. :ensure => 'present',
  41. :path => '/etc/systemd/system/postgresql-9.4.service',
  42. :owner => 'root',
  43. :group => 'root',
  44. })
  45. is_expected.to contain_file('systemd-override') \
  46. .with_content(/.include \/usr\/lib\/systemd\/system\/postgresql-9.4.service/)
  47. end
  48. end
  49. end
  50. describe 'on Fedora 21' do
  51. let :facts do
  52. {
  53. :osfamily => 'RedHat',
  54. :operatingsystem => 'Fedora',
  55. :operatingsystemrelease => '21',
  56. :concat_basedir => tmpfilename('server'),
  57. :kernel => 'Linux',
  58. :id => 'root',
  59. :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
  60. }
  61. end
  62. it 'should have the correct systemd-override file' do
  63. is_expected.to contain_file('systemd-override').with ({
  64. :ensure => 'present',
  65. :path => '/etc/systemd/system/postgresql.service',
  66. :owner => 'root',
  67. :group => 'root',
  68. })
  69. is_expected.to contain_file('systemd-override') \
  70. .with_content(/.include \/lib\/systemd\/system\/postgresql.service/)
  71. end
  72. describe 'with manage_package_repo => true and a version' do
  73. let (:pre_condition) do
  74. <<-EOS
  75. class { 'postgresql::globals':
  76. manage_package_repo => true,
  77. version => '9.4',
  78. }->
  79. class { 'postgresql::server': }
  80. EOS
  81. end
  82. it 'should have the correct systemd-override file' do
  83. is_expected.to contain_file('systemd-override').with ({
  84. :ensure => 'present',
  85. :path => '/etc/systemd/system/postgresql-9.4.service',
  86. :owner => 'root',
  87. :group => 'root',
  88. })
  89. is_expected.to contain_file('systemd-override') \
  90. .with_content(/.include \/lib\/systemd\/system\/postgresql-9.4.service/)
  91. end
  92. end
  93. end
  94. end