File: shared_examples.rb

package info (click to toggle)
puppet-module-murano 23.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 928 kB
  • sloc: ruby: 2,856; python: 38; sh: 10; makefile: 10
file content (67 lines) | stat: -rw-r--r-- 1,881 bytes parent folder | download
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
shared_examples_for "a Puppet::Error" do |description|
  it "with message matching #{description.inspect}" do
    expect { is_expected.to have_class_count(1) }.to raise_error(Puppet::Error, description)
  end
end

shared_examples 'generic murano service' do |service|

  context 'with default parameters' do
    let :context_params do
      { }
    end

    it 'installs package and service' do
      is_expected.to contain_package(service[:name]).with({
        :name   => service[:package_name],
        :ensure => 'present',
        :tag    => [ 'openstack', 'murano-package'],
      })
      is_expected.to contain_service(service[:name]).with({
        :name   => service[:service_name],
        :ensure => 'running',
        :enable => true,
        :tag    => 'murano-service',
      })
    end
  end

  context 'with overridden parameters' do
    let :context_params do
      { :enabled        => true,
        :package_ensure => '2014.2-1' }
    end

    let :params do
      context_params.merge(service[:extra_params].nil? ? {} : service[:extra_params])
    end

    it 'installs package and service' do
      is_expected.to contain_package(service[:name]).with({
        :name   => service[:package_name],
        :ensure => '2014.2-1',
        :tag    => [ 'openstack', 'murano-package'],
      })
      is_expected.to contain_service(service[:name]).with({
        :name   => service[:service_name],
        :ensure => 'running',
        :enable => true,
        :tag    => 'murano-service',
      })
    end
  end

  context 'while not managing service state' do
    let :context_params do
      { :manage_service => false }
    end

    let :params do
      context_params.merge(service[:extra_params].nil? ? {} : service[:extra_params])
    end

    it 'does not control service state' do
      is_expected.to_not contain_service(service[:name])
    end
  end
end