Skip to content

Commit 68c1852

Browse files
committed
100% unit test coverage
1 parent f648b4a commit 68c1852

25 files changed

+1715
-1126
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'puppetdb::database::default_read_grant' do
6+
valid = {
7+
'standard': {
8+
database_name: 'puppetdb',
9+
schema: 'public',
10+
database_username: 'puppetdb',
11+
database_read_only_username: 'puppetdb-read',
12+
}
13+
}
14+
15+
invalid = {
16+
'no params': {},
17+
'without database_name': {
18+
schema: 'public',
19+
database_username: 'puppetdb',
20+
database_read_only_username: 'puppetdb-read',
21+
}
22+
}
23+
24+
let(:facts) { on_supported_os.take(1).first[1] }
25+
let(:pre_condition) { 'include postgresql::server' }
26+
let(:name) { title }
27+
let(:args) { params }
28+
29+
context 'with valid parameters' do
30+
valid.each do |name, params|
31+
context name do
32+
include_examples 'puppetdb::database::default_read_grant' do
33+
let(:title) { name.to_s }
34+
let(:params) { params }
35+
end
36+
end
37+
end
38+
end
39+
40+
context 'with invalid parameters' do
41+
invalid.each do |name, params|
42+
context name do
43+
include_examples 'puppetdb::database::default_read_grant', Puppet::Error do
44+
let(:title) { name.to_s }
45+
let(:params) { params }
46+
end
47+
end
48+
end
49+
end
50+
end
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
valid = {
6+
'puppetdb-read': {
7+
database_name: 'puppetdb',
8+
database_username: 'monitor',
9+
puppetdb_server: 'localhost',
10+
},
11+
'monitor': {
12+
database_name: 'opensesame',
13+
database_username: 'grover',
14+
puppetdb_server: 'rainbow',
15+
},
16+
}
17+
18+
invalid = {
19+
'no params': {},
20+
}
21+
22+
describe 'puppetdb::database::postgresql_ssl_rules' do
23+
let(:facts) { on_supported_os.take(1).first[1] }
24+
let(:pre_condition) { 'include postgresql::server' }
25+
let(:name) { title }
26+
let(:args) { params }
27+
28+
valid.each do |name, params|
29+
context "for valid #{name}" do
30+
include_examples 'puppetdb::database::postgresql_ssl_rules' do
31+
let(:title) { name.to_s }
32+
let(:params) { params }
33+
end
34+
end
35+
end
36+
37+
invalid.each do |name, params|
38+
context "for invalid #{name}" do
39+
include_examples 'puppetdb::database::postgresql_ssl_rules', Puppet::Error do
40+
let(:title) { name.to_s }
41+
let(:params) { params }
42+
end
43+
end
44+
end
45+
end
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
valid = {
6+
'grant read on new objects from blah to blah': {
7+
database_read_only_username: 'puppetdb-read',
8+
database_name: 'puppetdb',
9+
schema: 'public',
10+
},
11+
}
12+
13+
invalid = {
14+
'no params': {},
15+
}
16+
17+
describe 'puppetdb::database::read_grant' do
18+
let(:facts) { on_supported_os.take(1).first[1] }
19+
let(:pre_condition) { 'include postgresql::server' }
20+
let(:name) { title }
21+
let(:args) { params }
22+
23+
valid.each do |name, params|
24+
context "for valid #{name}" do
25+
include_examples 'puppetdb::database::read_grant' do
26+
let(:title) { name.to_s }
27+
let(:params) { params }
28+
end
29+
end
30+
end
31+
32+
invalid.each do |name, params|
33+
context "for invalid #{name}" do
34+
include_examples 'puppetdb::database::read_grant', Puppet::Error do
35+
let(:title) { name.to_s }
36+
let(:params) { params }
37+
end
38+
end
39+
end
40+
end
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
valid = {
6+
'puppetdb-read': {
7+
read_database_username: 'puppetdb-read',
8+
database_name: 'puppetdb',
9+
password_hash: 'blah',
10+
database_owner: 'puppetdb',
11+
},
12+
'spectest': {
13+
read_database_username: 'spectest-read',
14+
database_name: 'spectest',
15+
database_owner: 'spectest',
16+
},
17+
}
18+
19+
invalid = {
20+
'no params': {},
21+
}
22+
23+
describe 'puppetdb::database::read_only_user', type: :define do
24+
let(:facts) { on_supported_os.take(1).first[1] }
25+
let(:pre_condition) { 'include postgresql::server' }
26+
let(:name) { title }
27+
let(:args) { params }
28+
29+
valid.each do |name, params|
30+
context "for valid #{name}" do
31+
include_examples 'puppetdb::database::read_only_user' do
32+
let(:title) { name.to_s }
33+
let(:params) { params }
34+
end
35+
end
36+
end
37+
38+
invalid.each do |name, params|
39+
context "for invalid #{name}" do
40+
include_examples 'puppetdb::database::read_only_user', Puppet::Error do
41+
let(:title) { name.to_s }
42+
let(:params) { params }
43+
end
44+
end
45+
end
46+
end

0 commit comments

Comments
 (0)