newer pg module
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / spec / acceptance / 00-utf8_encoding_spec.rb
1 require 'spec_helper_acceptance'
2
3 # These tests are designed to ensure that the module, when ran with defaults,
4 # sets up everything correctly and allows us to connect to Postgres.
5 describe 'postgresql::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
6   it 'with defaults' do
7     pp = <<-EOS
8       class { 'postgresql::globals':
9         encoding => 'UTF8',
10         locale   => 'en_NG',
11       } ->
12       class { 'postgresql::server': }
13     EOS
14
15     apply_manifest(pp, :catch_failures => true)
16     apply_manifest(pp, :catch_changes => true)
17   end
18
19   describe port(5432) do
20     it { is_expected.to be_listening }
21   end
22
23   it 'can connect with psql' do
24     psql('--command="\l" postgres', 'postgres') do |r|
25       expect(r.stdout).to match(/List of databases/)
26     end
27   end
28
29   it 'must set UTF8 as template1 encoding' do
30     psql('--command="SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname=\'template1\'"') do |r|
31       expect(r.stdout).to match(/UTF8/)
32     end
33   end
34 end
35
36
37