Browse Source

Merge "Remove redundantly tested code"

Zuul 3 months ago
parent
commit
890b23abec
1 changed files with 10 additions and 68 deletions
  1. 10
    68
      spec/classes/glare_db_spec.rb

+ 10
- 68
spec/classes/glare_db_spec.rb View File

@@ -1,10 +1,11 @@
1 1
 require 'spec_helper'
2 2
 
3 3
 describe 'glare::db' do
4
-
5 4
   shared_examples 'glare::db' do
6 5
     context 'with default parameters' do
7
-      it { is_expected.to contain_oslo__db('glare_config').with(
6
+      it { should contain_class('glare::deps') }
7
+
8
+      it { should contain_oslo__db('glare_config').with(
8 9
         :db_max_retries => '<SERVICE DEFAULT>',
9 10
         :connection     => 'sqlite:////var/lib/glare/glare.sqlite',
10 11
         :idle_timeout   => '<SERVICE DEFAULT>',
@@ -19,7 +20,8 @@ describe 'glare::db' do
19 20
 
20 21
     context 'with specific parameters' do
21 22
       let :params do
22
-        { :database_connection     => 'mysql+pymysql://glare:glare@localhost/glare',
23
+        {
24
+          :database_connection     => 'mysql+pymysql://glare:glare@localhost/glare',
23 25
           :database_idle_timeout   => '3601',
24 26
           :database_min_pool_size  => '2',
25 27
           :database_db_max_retries => '-1',
@@ -31,7 +33,9 @@ describe 'glare::db' do
31 33
         }
32 34
       end
33 35
 
34
-      it { is_expected.to contain_oslo__db('glare_config').with(
36
+      it { should contain_class('glare::deps') }
37
+
38
+      it { should contain_oslo__db('glare_config').with(
35 39
         :db_max_retries => '-1',
36 40
         :connection     => 'mysql+pymysql://glare:glare@localhost/glare',
37 41
         :idle_timeout   => '3601',
@@ -43,79 +47,17 @@ describe 'glare::db' do
43 47
         :pool_timeout   => '21',
44 48
       )}
45 49
     end
46
-
47
-    context 'with postgresql backend' do
48
-      let :params do
49
-        { :database_connection => 'postgresql://glare:glare@localhost/glare', }
50
-      end
51
-
52
-      it 'install the proper backend package' do
53
-        is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
54
-      end
55
-
56
-    end
57
-
58
-    context 'with MySQL-python library as backend package' do
59
-      let :params do
60
-        { :database_connection => 'mysql://glare:glare@localhost/glare', }
61
-      end
62
-
63
-      it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
64
-    end
65
-
66
-    context 'with incorrect database_connection string' do
67
-      let :params do
68
-        { :database_connection => 'foodb://glare:glare@localhost/glare', }
69
-      end
70
-
71
-      it_raises 'a Puppet::Error', /validate_re/
72
-    end
73
-
74
-    context 'with incorrect pymysql database_connection string' do
75
-      let :params do
76
-        { :database_connection => 'foo+pymysql://glare:glare@localhost/glare', }
77
-      end
78
-
79
-      it_raises 'a Puppet::Error', /validate_re/
80
-    end
81
-
82
-  end
83
-
84
-  shared_examples_for 'glare::db on Debian' do
85
-    context 'using pymysql driver' do
86
-      let :params do
87
-        { :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
88
-      end
89
-
90
-      it 'install the proper backend package' do
91
-        is_expected.to contain_package('python-pymysql').with(
92
-          :ensure => 'present',
93
-          :name   => 'python-pymysql',
94
-          :tag    => 'openstack'
95
-        )
96
-      end
97
-    end
98
-  end
99
-
100
-  shared_examples_for 'glare::db on RedHat' do
101
-    context 'using pymysql driver' do
102
-      let :params do
103
-        { :database_connection => 'mysql+pymysql://glare:glare@localhost/glare', }
104
-      end
105
-
106
-    end
107 50
   end
108 51
 
109 52
   on_supported_os({
110
-    :supported_os   => OSDefaults.get_supported_os
53
+    :supported_os => OSDefaults.get_supported_os
111 54
   }).each do |os,facts|
112 55
     context "on #{os}" do
113 56
       let (:facts) do
114 57
         facts.merge!(OSDefaults.get_facts())
115 58
       end
116 59
 
117
-      it_configures 'glare::db'
118
-      it_configures "glare::db on #{facts[:osfamily]}"
60
+      it_behaves_like 'glare::db'
119 61
     end
120 62
   end
121 63
 end

Loading…
Cancel
Save