|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
3 | 3 | describe 'mongodb::db', :type => :define do |
4 | | - let(:title) { 'testdb' } |
| 4 | + context 'default' do |
| 5 | + let(:title) { 'testdb' } |
5 | 6 |
|
6 | | - let(:params) { |
7 | | - { 'user' => 'testuser', |
8 | | - 'password' => 'testpass', |
| 7 | + let(:params) { |
| 8 | + { 'user' => 'testuser', |
| 9 | + 'password' => 'testpass', |
| 10 | + } |
9 | 11 | } |
10 | | - } |
11 | 12 |
|
12 | | - it 'should contain mongodb_database with mongodb::server requirement' do |
13 | | - is_expected.to contain_mongodb_database('testdb') |
14 | | - end |
| 13 | + it 'should contain mongodb_database with mongodb::server requirement' do |
| 14 | + is_expected.to contain_mongodb_database('testdb') |
| 15 | + end |
15 | 16 |
|
16 | | - it 'should contain mongodb_user with mongodb_database requirement' do |
17 | | - is_expected.to contain_mongodb_user('User testuser on db testdb').with({ |
18 | | - 'username' => 'testuser', |
19 | | - 'database' => 'testdb', |
20 | | - 'require' => 'Mongodb_database[testdb]', |
21 | | - }) |
22 | | - end |
| 17 | + it 'should contain mongodb_user with mongodb_database requirement' do |
| 18 | + is_expected.to contain_mongodb_user('User testuser on db testdb').with({ |
| 19 | + 'username' => 'testuser', |
| 20 | + 'database' => 'testdb', |
| 21 | + 'require' => 'Mongodb_database[testdb]', |
| 22 | + }) |
| 23 | + end |
23 | 24 |
|
24 | | - it 'should contain mongodb_user with proper roles' do |
25 | | - params.merge!({'roles' => ['testrole1', 'testrole2']}) |
26 | | - is_expected.to contain_mongodb_user('User testuser on db testdb')\ |
27 | | - .with_roles(["testrole1", "testrole2"]) |
28 | | - end |
| 25 | + it 'should contain mongodb_user with proper roles' do |
| 26 | + params.merge!({'roles' => ['testrole1', 'testrole2']}) |
| 27 | + is_expected.to contain_mongodb_user('User testuser on db testdb')\ |
| 28 | + .with_roles(["testrole1", "testrole2"]) |
| 29 | + end |
29 | 30 |
|
30 | | - it 'should prefer password_hash instead of password' do |
31 | | - params.merge!({'password_hash' => 'securehash'}) |
32 | | - is_expected.to contain_mongodb_user('User testuser on db testdb')\ |
33 | | - .with_password_hash('securehash') |
| 31 | + it 'should prefer password_hash instead of password' do |
| 32 | + params.merge!({'password_hash' => 'securehash'}) |
| 33 | + is_expected.to contain_mongodb_user('User testuser on db testdb')\ |
| 34 | + .with_password_hash('securehash') |
| 35 | + end |
| 36 | + |
| 37 | + it 'should contain mongodb_database with proper tries param' do |
| 38 | + params.merge!({'tries' => 5}) |
| 39 | + is_expected.to contain_mongodb_database('testdb').with_tries(5) |
| 40 | + end |
34 | 41 | end |
35 | 42 |
|
36 | | - it 'should contain mongodb_database with proper tries param' do |
37 | | - params.merge!({'tries' => 5}) |
38 | | - is_expected.to contain_mongodb_database('testdb').with_tries(5) |
| 43 | + context 'with a db_name value' do |
| 44 | + let(:title) { 'testdb-title' } |
| 45 | + |
| 46 | + let(:params) { |
| 47 | + { |
| 48 | + 'db_name' => 'testdb', |
| 49 | + 'user' => 'testuser', |
| 50 | + 'password' => 'testpass', |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + it 'should contain mongodb_database with mongodb::server requirement' do |
| 55 | + is_expected.to contain_mongodb_database('testdb') |
| 56 | + end |
| 57 | + |
| 58 | + it 'should contain mongodb_user with mongodb_database requirement' do |
| 59 | + is_expected.to contain_mongodb_user('User testuser on db testdb').with({ |
| 60 | + 'username' => 'testuser', |
| 61 | + 'database' => 'testdb', |
| 62 | + 'require' => 'Mongodb_database[testdb]', |
| 63 | + }) |
| 64 | + end |
| 65 | + |
| 66 | + it 'should contain mongodb_user with proper roles' do |
| 67 | + params.merge!({'roles' => ['testrole1', 'testrole2']}) |
| 68 | + is_expected.to contain_mongodb_user('User testuser on db testdb')\ |
| 69 | + .with_roles(["testrole1", "testrole2"]) |
| 70 | + end |
| 71 | + |
| 72 | + it 'should prefer password_hash instead of password' do |
| 73 | + params.merge!({'password_hash' => 'securehash'}) |
| 74 | + is_expected.to contain_mongodb_user('User testuser on db testdb')\ |
| 75 | + .with_password_hash('securehash') |
| 76 | + end |
| 77 | + |
| 78 | + it 'should contain mongodb_database with proper tries param' do |
| 79 | + params.merge!({'tries' => 5}) |
| 80 | + is_expected.to contain_mongodb_database('testdb').with_tries(5) |
| 81 | + end |
39 | 82 | end |
40 | 83 | end |
0 commit comments