summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Urdin <tobias.urdin@binero.se>2019-01-18 10:34:52 +0100
committerTobias Urdin <tobias.urdin@binero.se>2019-01-18 10:34:52 +0100
commitca287bfe488e15361368e109e01608ae6b7ecc1c (patch)
treea38a965d0cde5070b0b5f1b70758663c1f622884
parent0e918ef49886f328a4eec491ba23a290682f449f (diff)
Remove redundantly tested code
Remove code that is redundantly tested. This should not be tested here but in puppet-oslo where this logic resides. If we keep this and we do changes in puppet-oslo we will break these unit tests, this is something we need to sort out for all modules. Change-Id: I96eeeeec72ac565f2917e94359c449bab85577db
Notes
Notes (review): Code-Review+2: Emilien Macchi <emilien@redhat.com> Code-Review+2: Alex Schultz <aschultz@redhat.com> Workflow+1: Alex Schultz <aschultz@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Sat, 19 Jan 2019 01:26:47 +0000 Reviewed-on: https://review.openstack.org/631740 Project: openstack/puppet-heat Branch: refs/heads/master
-rw-r--r--spec/classes/heat_db_spec.rb72
1 files changed, 11 insertions, 61 deletions
diff --git a/spec/classes/heat_db_spec.rb b/spec/classes/heat_db_spec.rb
index 96c68d0..eb62aeb 100644
--- a/spec/classes/heat_db_spec.rb
+++ b/spec/classes/heat_db_spec.rb
@@ -1,13 +1,11 @@
1require 'spec_helper' 1require 'spec_helper'
2 2
3describe 'heat::db' do 3describe 'heat::db' do
4
5 shared_examples 'heat::db' do 4 shared_examples 'heat::db' do
6
7 context 'with default parameters' do 5 context 'with default parameters' do
6 it { should contain_class('heat::deps') }
8 7
9 it { is_expected.to contain_class('heat::db::sync') } 8 it { should contain_oslo__db('heat_config').with(
10 it { is_expected.to contain_oslo__db('heat_config').with(
11 :db_max_retries => '<SERVICE DEFAULT>', 9 :db_max_retries => '<SERVICE DEFAULT>',
12 :connection => 'sqlite:////var/lib/heat/heat.sqlite', 10 :connection => 'sqlite:////var/lib/heat/heat.sqlite',
13 :idle_timeout => '<SERVICE DEFAULT>', 11 :idle_timeout => '<SERVICE DEFAULT>',
@@ -19,11 +17,13 @@ describe 'heat::db' do
19 :pool_timeout => '<SERVICE DEFAULT>', 17 :pool_timeout => '<SERVICE DEFAULT>',
20 )} 18 )}
21 19
20 it { should contain_class('heat::db::sync') }
22 end 21 end
23 22
24 context 'with specific parameters' do 23 context 'with specific parameters' do
25 let :params do 24 let :params do
26 { :database_connection => 'mysql+pymysql://heat:heat@localhost/heat', 25 {
26 :database_connection => 'mysql+pymysql://heat:heat@localhost/heat',
27 :database_idle_timeout => '3601', 27 :database_idle_timeout => '3601',
28 :database_min_pool_size => '2', 28 :database_min_pool_size => '2',
29 :database_max_pool_size => '12', 29 :database_max_pool_size => '12',
@@ -32,11 +32,13 @@ describe 'heat::db' do
32 :database_db_max_retries => '-1', 32 :database_db_max_retries => '-1',
33 :database_max_overflow => '21', 33 :database_max_overflow => '21',
34 :database_pool_timeout => '21', 34 :database_pool_timeout => '21',
35 :sync_db => false } 35 :sync_db => false
36 }
36 end 37 end
37 38
38 it { is_expected.not_to contain_class('heat::db::sync') } 39 it { should contain_class('heat::deps') }
39 it { is_expected.to contain_oslo__db('heat_config').with( 40
41 it { should contain_oslo__db('heat_config').with(
40 :db_max_retries => '-1', 42 :db_max_retries => '-1',
41 :connection => 'mysql+pymysql://heat:heat@localhost/heat', 43 :connection => 'mysql+pymysql://heat:heat@localhost/heat',
42 :idle_timeout => '3601', 44 :idle_timeout => '3601',
@@ -48,45 +50,8 @@ describe 'heat::db' do
48 :pool_timeout => '21', 50 :pool_timeout => '21',
49 )} 51 )}
50 52
53 it { should_not contain_class('heat::db::sync') }
51 end 54 end
52
53 context 'with MySQL-python library as backend package' do
54 let :params do
55 { :database_connection => 'mysql://heat:heat@localhost/heat' }
56 end
57
58 it { is_expected.to contain_oslo__db('heat_config').with(
59 :connection => 'mysql://heat:heat@localhost/heat',
60 )}
61 end
62
63 context 'with postgresql backend' do
64 let :params do
65 { :database_connection => 'postgresql://heat:heat@localhost/heat', }
66 end
67
68 it 'install the proper backend package' do
69 is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
70 end
71
72 end
73
74 context 'with incorrect database_connection string' do
75 let :params do
76 { :database_connection => 'redis://heat:heat@localhost/heat', }
77 end
78
79 it_raises 'a Puppet::Error', /validate_re/
80 end
81
82 context 'with incorrect database_connection string' do
83 let :params do
84 { :database_connection => 'foo+pymysql://heat:heat@localhost/heat', }
85 end
86
87 it_raises 'a Puppet::Error', /validate_re/
88 end
89
90 end 55 end
91 56
92 on_supported_os({ 57 on_supported_os({
@@ -98,21 +63,6 @@ describe 'heat::db' do
98 end 63 end
99 64
100 it_behaves_like 'heat::db' 65 it_behaves_like 'heat::db'
101
102 context 'using pymysql driver' do
103 let :params do
104 { :database_connection => 'mysql+pymysql://heat:heat@localhost/heat' }
105 end
106
107 case facts[:osfamily]
108 when 'Debian'
109 it { is_expected.to contain_package('python-pymysql').with({ :ensure => 'present', :name => 'python-pymysql' }) }
110 when 'RedHat'
111 it { is_expected.not_to contain_package('python-pymysql') }
112 end
113 end
114
115 end 66 end
116 end 67 end
117
118end 68end