]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/openstacklib/spec/defines/openstacklib_service_validation_spec.rb
17e4389a69afd46ca36f39cc2e7ed49c706902ff
[dsa-puppet.git] / 3rdparty / modules / openstacklib / spec / defines / openstacklib_service_validation_spec.rb
1 #
2 # Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17
18 require 'spec_helper'
19
20 describe 'openstacklib::service_validation' do
21
22   let (:title) { 'nova-api' }
23
24   let :required_params do
25     { :command => 'nova list' }
26   end
27
28   shared_examples 'openstacklib::service_validation examples' do
29
30     context 'with only required parameters' do
31       let :params do
32         required_params
33       end
34
35       it { should contain_exec("execute #{title} validation").with(
36         :path      => '/usr/bin:/bin:/usr/sbin:/sbin',
37         :provider  => 'shell',
38         :command   => 'nova list',
39         :tries     => '10',
40         :try_sleep => '2',
41       )}
42
43       it { should contain_anchor("create #{title} anchor").with(
44         :require => "Exec[execute #{title} validation]",
45       )}
46
47     end
48
49     context 'when omitting a required parameter command' do
50       let :params do
51         required_params.delete(:command)
52       end
53       it { expect { should raise_error(Puppet::Error) } }
54     end
55
56   end
57
58   context 'on a Debian osfamily' do
59     let :facts do
60       { :osfamily => "Debian" }
61     end
62
63     include_examples 'openstacklib::service_validation examples'
64   end
65
66   context 'on a RedHat osfamily' do
67     let :facts do
68       { :osfamily => 'RedHat' }
69     end
70
71     include_examples 'openstacklib::service_validation examples'
72   end
73 end