-
Notifications
You must be signed in to change notification settings - Fork 611
/
Copy pathdatabase_spec.rb
72 lines (54 loc) · 2.41 KB
/
database_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# frozen_string_literal: true
require 'spec_helper'
describe 'postgresql::server::database' do
include_examples 'Debian 11'
let :title do
'test'
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { is_expected.to contain_postgresql__server__database('test') }
it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').that_requires('Service[postgresqld_instance_main]') }
context "with comment set to 'test comment'" do
let(:params) { { comment: 'test comment' } }
it { is_expected.to contain_postgresql_psql("COMMENT ON DATABASE \"test\" IS 'test comment'").with_connect_settings({}) }
end
context 'with specific db connection settings - default port' do
let :pre_condition do
"class {'postgresql::server':}"
end
let(:params) do
{ connect_settings: { 'PGHOST' => 'postgres-db-server',
'DBVERSION' => '9.1' } }
end
it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').with_connect_settings('PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1').with_port(5432) }
end
context 'with specific db connection settings - including port' do
let :pre_condition do
"class {'postgresql::globals':}
class {'postgresql::server':}"
end
let(:params) do
{ connect_settings: { 'PGHOST' => 'postgres-db-server',
'DBVERSION' => '9.1',
'PGPORT' => '1234' } }
end
it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').with_connect_settings('PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.1', 'PGPORT' => '1234').with_port(1234) }
end
context 'with global db connection settings - including port' do
let :pre_condition do
"class {'postgresql::globals':
default_connect_settings => { 'PGHOST' => 'postgres-db-server',
'DBVERSION' => '9.2',
'PGPORT' => '1234' }
}
class {'postgresql::server':}"
end
it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').with_connect_settings('PGHOST' => 'postgres-db-server', 'DBVERSION' => '9.2', 'PGPORT' => '1234').with_port(1234) }
end
context 'with different owner' do
let(:params) { { owner: 'test_owner' } }
it { is_expected.to contain_postgresql_psql('ALTER DATABASE "test" OWNER TO "test_owner"') }
end
end