|
3 | 3 | require 'spec_helper'
|
4 | 4 |
|
5 | 5 | describe 'mysql::server' do
|
| 6 | + subject(:server) { described_class.new } |
| 7 | + |
6 | 8 | on_supported_os.each do |os, facts|
|
7 | 9 | context "my.cnf template - on #{os}" do
|
8 | 10 | let(:facts) do
|
|
13 | 15 | let(:params) { { override_options: { 'mysqld' => { 'socket' => '/var/lib/mysql/mysql.sock' } } } }
|
14 | 16 |
|
15 | 17 | it do
|
16 |
| - expect(subject).to contain_file('mysql-config-file').with(mode: '0644', |
17 |
| - selinux_ignore_defaults: true).with_content(%r{socket = \/var\/lib\/mysql\/mysql.sock}) |
| 18 | + expect(server).to contain_file('mysql-config-file').with(mode: '0644', |
| 19 | + selinux_ignore_defaults: true).with_content(%r{socket = \/var\/lib\/mysql\/mysql.sock}) |
18 | 20 | end
|
19 | 21 | end
|
20 | 22 |
|
21 | 23 | describe 'array entry' do
|
22 | 24 | let(:params) { { override_options: { 'mysqld' => { 'replicate-do-db' => ['base1', 'base2'] } } } }
|
23 | 25 |
|
24 | 26 | it do
|
25 |
| - expect(subject).to contain_file('mysql-config-file').with_content( |
| 27 | + expect(server).to contain_file('mysql-config-file').with_content( |
26 | 28 | %r{.*replicate-do-db = base1\nreplicate-do-db = base2.*},
|
27 | 29 | )
|
28 | 30 | end
|
|
80 | 82 | let(:params) { { includedir: '/etc/my.cnf.d' } }
|
81 | 83 |
|
82 | 84 | it 'makes the directory' do
|
83 |
| - expect(subject).to contain_file('/etc/my.cnf.d').with(ensure: :directory, |
84 |
| - mode: '0755') |
| 85 | + expect(server).to contain_file('/etc/my.cnf.d').with(ensure: :directory, |
| 86 | + mode: '0755') |
85 | 87 | end
|
86 | 88 |
|
87 | 89 | it { is_expected.to contain_file('mysql-config-file').with_content(%r{!includedir}) }
|
|
91 | 93 | let(:params) { { includedir: '' } }
|
92 | 94 |
|
93 | 95 | it 'shouldnt contain the directory' do
|
94 |
| - expect(subject).not_to contain_file('mysql-config-file').with(ensure: :directory, |
95 |
| - mode: '0755') |
| 96 | + expect(server).not_to contain_file('mysql-config-file').with(ensure: :directory, |
| 97 | + mode: '0755') |
96 | 98 | end
|
97 | 99 |
|
98 | 100 | it { is_expected.to contain_file('mysql-config-file').without_content(%r{!includedir}) }
|
|
102 | 104 | let(:params) { { 'config_file_mode' => '0644' } }
|
103 | 105 |
|
104 | 106 | it do
|
105 |
| - expect(subject).to contain_file('mysql-config-file').with(mode: '0644') |
| 107 | + expect(server).to contain_file('mysql-config-file').with(mode: '0644') |
106 | 108 | end
|
107 | 109 | end
|
108 | 110 |
|
109 | 111 | context 'with file mode 0664' do
|
110 | 112 | let(:params) { { 'config_file_mode' => '0664' } }
|
111 | 113 |
|
112 | 114 | it do
|
113 |
| - expect(subject).to contain_file('mysql-config-file').with(mode: '0664') |
| 115 | + expect(server).to contain_file('mysql-config-file').with(mode: '0664') |
114 | 116 | end
|
115 | 117 | end
|
116 | 118 |
|
117 | 119 | context 'with file mode 0660' do
|
118 | 120 | let(:params) { { 'config_file_mode' => '0660' } }
|
119 | 121 |
|
120 | 122 | it do
|
121 |
| - expect(subject).to contain_file('mysql-config-file').with(mode: '0660') |
| 123 | + expect(server).to contain_file('mysql-config-file').with(mode: '0660') |
122 | 124 | end
|
123 | 125 | end
|
124 | 126 |
|
125 | 127 | context 'with file mode 0641' do
|
126 | 128 | let(:params) { { 'config_file_mode' => '0641' } }
|
127 | 129 |
|
128 | 130 | it do
|
129 |
| - expect(subject).to contain_file('mysql-config-file').with(mode: '0641') |
| 131 | + expect(server).to contain_file('mysql-config-file').with(mode: '0641') |
130 | 132 | end
|
131 | 133 | end
|
132 | 134 |
|
133 | 135 | context 'with file mode 0610' do
|
134 | 136 | let(:params) { { 'config_file_mode' => '0610' } }
|
135 | 137 |
|
136 | 138 | it do
|
137 |
| - expect(subject).to contain_file('mysql-config-file').with(mode: '0610') |
| 139 | + expect(server).to contain_file('mysql-config-file').with(mode: '0610') |
138 | 140 | end
|
139 | 141 | end
|
140 | 142 |
|
141 | 143 | context 'with file 0600' do
|
142 | 144 | let(:params) { { 'config_file_mode' => '0600' } }
|
143 | 145 |
|
144 | 146 | it do
|
145 |
| - expect(subject).to contain_file('mysql-config-file').with(mode: '0600') |
| 147 | + expect(server).to contain_file('mysql-config-file').with(mode: '0600') |
146 | 148 | end
|
147 | 149 | end
|
148 | 150 |
|
149 | 151 | context 'user owner 12345' do
|
150 | 152 | let(:params) { { 'mycnf_owner' => '12345' } }
|
151 | 153 |
|
152 | 154 | it do
|
153 |
| - expect(subject).to contain_file('mysql-config-file').with( |
| 155 | + expect(server).to contain_file('mysql-config-file').with( |
154 | 156 | owner: '12345',
|
155 | 157 | )
|
156 | 158 | end
|
|
160 | 162 | let(:params) { { 'mycnf_group' => '12345' } }
|
161 | 163 |
|
162 | 164 | it do
|
163 |
| - expect(subject).to contain_file('mysql-config-file').with( |
| 165 | + expect(server).to contain_file('mysql-config-file').with( |
164 | 166 | group: '12345',
|
165 | 167 | )
|
166 | 168 | end
|
|
170 | 172 | let(:params) { { 'mycnf_owner' => '12345', 'mycnf_group' => '12345' } }
|
171 | 173 |
|
172 | 174 | it do
|
173 |
| - expect(subject).to contain_file('mysql-config-file').with( |
| 175 | + expect(server).to contain_file('mysql-config-file').with( |
174 | 176 | owner: '12345',
|
175 | 177 | group: '12345',
|
176 | 178 | )
|
|
0 commit comments