forked from puppetlabs/puppetlabs-mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql_password_spec.rb
41 lines (32 loc) · 1.21 KB
/
mysql_password_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
require 'spec_helper'
shared_examples 'mysql::password function' do
it 'exists' do
is_expected.not_to eq(nil)
end
it 'raises a ArgumentError if there is less than 1 arguments' do
is_expected.to run.with_params.and_raise_error(ArgumentError)
end
it 'raises a ArgumentError if there is more than 1 arguments' do
is_expected.to run.with_params('foo', 'bar').and_raise_error(ArgumentError)
end
it 'converts password into a hash' do
is_expected.to run.with_params('password').and_return('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')
end
it 'password should be String' do
is_expected.to run.with_params(123).and_raise_error(ArgumentError)
end
it 'converts an empty password into a empty string' do
is_expected.to run.with_params('').and_return('')
end
it 'does not convert a password that is already a hash' do
is_expected.to run.with_params('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19').and_return('*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19')
end
end
describe 'mysql::password' do
it_behaves_like 'mysql::password function'
describe 'non-namespaced shim' do
describe 'mysql_password', type: :puppet_function do
it_behaves_like 'mysql::password function'
end
end
end