| 1 |
require 'spec_helper_acceptance' |
| 2 |
|
| 3 |
describe 'basic cloudkitty_config resource' do |
| 4 |
|
| 5 |
context 'default parameters' do |
| 6 |
|
| 7 |
it 'should work with no errors' do |
| 8 |
pp= <<-EOS |
| 9 |
Exec { logoutput => 'on_failure' } |
| 10 |
|
| 11 |
File <||> -> Cloudkitty_config <||> |
| 12 |
File <||> -> Cloudkitty_api_paste_ini <||> |
| 13 |
|
| 14 |
file { '/etc/cloudkitty' : |
| 15 |
ensure => directory, |
| 16 |
} |
| 17 |
file { '/etc/cloudkitty/cloudkitty.conf' : |
| 18 |
ensure => file, |
| 19 |
} |
| 20 |
file { '/etc/cloudkitty/api_paste.ini' : |
| 21 |
ensure => file, |
| 22 |
} |
| 23 |
|
| 24 |
cloudkitty_config { 'DEFAULT/thisshouldexist' : |
| 25 |
value => 'foo', |
| 26 |
} |
| 27 |
|
| 28 |
cloudkitty_config { 'DEFAULT/thisshouldnotexist' : |
| 29 |
value => '<SERVICE DEFAULT>', |
| 30 |
} |
| 31 |
|
| 32 |
cloudkitty_config { 'DEFAULT/thisshouldexist2' : |
| 33 |
value => '<SERVICE DEFAULT>', |
| 34 |
ensure_absent_val => 'toto', |
| 35 |
} |
| 36 |
|
| 37 |
cloudkitty_config { 'DEFAULT/thisshouldnotexist2' : |
| 38 |
value => 'toto', |
| 39 |
ensure_absent_val => 'toto', |
| 40 |
} |
| 41 |
|
| 42 |
cloudkitty_config { 'DEFAULT/thisshouldexist3' : |
| 43 |
value => ['foo', 'bar'], |
| 44 |
} |
| 45 |
|
| 46 |
cloudkitty_api_paste_ini { 'DEFAULT/thisshouldexist' : |
| 47 |
value => 'foo', |
| 48 |
} |
| 49 |
|
| 50 |
cloudkitty_api_paste_ini { 'DEFAULT/thisshouldnotexist' : |
| 51 |
value => '<SERVICE DEFAULT>', |
| 52 |
} |
| 53 |
|
| 54 |
cloudkitty_api_paste_ini { 'DEFAULT/thisshouldexist2' : |
| 55 |
value => '<SERVICE DEFAULT>', |
| 56 |
ensure_absent_val => 'toto', |
| 57 |
} |
| 58 |
|
| 59 |
cloudkitty_api_paste_ini { 'DEFAULT/thisshouldnotexist2' : |
| 60 |
value => 'toto', |
| 61 |
ensure_absent_val => 'toto', |
| 62 |
} |
| 63 |
|
| 64 |
cloudkitty_api_paste_ini { 'DEFAULT/thisshouldexist3' : |
| 65 |
value => 'foo', |
| 66 |
key_val_separator => ':' |
| 67 |
} |
| 68 |
EOS |
| 69 |
|
| 70 |
|
| 71 |
# Run it twice and test for idempotency |
| 72 |
apply_manifest(pp, :catch_failures => true) |
| 73 |
apply_manifest(pp, :catch_changes => true) |
| 74 |
end |
| 75 |
|
| 76 |
describe file('/etc/cloudkitty/cloudkitty.conf') do |
| 77 |
it { is_expected.to exist } |
| 78 |
it { is_expected.to contain('thisshouldexist=foo') } |
| 79 |
it { is_expected.to contain('thisshouldexist2=<SERVICE DEFAULT>') } |
| 80 |
it { is_expected.to contain('thisshouldexist3=foo') } |
| 81 |
it { is_expected.to contain('thisshouldexist3=bar') } |
| 82 |
|
| 83 |
describe '#content' do |
| 84 |
subject { super().content } |
| 85 |
it { is_expected.to_not match /thisshouldnotexist/ } |
| 86 |
end |
| 87 |
end |
| 88 |
|
| 89 |
describe file('/etc/cloudkitty/api_paste.ini') do |
| 90 |
it { is_expected.to exist } |
| 91 |
it { is_expected.to contain('thisshouldexist=foo') } |
| 92 |
it { is_expected.to contain('thisshouldexist2=<SERVICE DEFAULT>') } |
| 93 |
it { is_expected.to contain('thisshouldexist3:foo') } |
| 94 |
|
| 95 |
describe '#content' do |
| 96 |
subject { super().content } |
| 97 |
it { is_expected.to_not match /thisshouldnotexist/ } |
| 98 |
end |
| 99 |
end |
| 100 |
end |
| 101 |
end |