File: ovs_spec.rb

package info (click to toggle)
puppet-module-vswitch 21.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 596 kB
  • sloc: ruby: 2,189; python: 38; sh: 10; makefile: 10
file content (55 lines) | stat: -rw-r--r-- 1,408 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
require 'spec_helper'

describe Puppet::Type.type(:vs_ssl).provider(:ovs) do
  let :ssl_attrs do
    {
      :name      => 'system',
      :ensure    => 'present',
    }
  end

  let :resource do
     Puppet::Type::Vs_ssl.new(ssl_attrs)
  end

  let :provider do
    described_class.new(resource)
  end

  context 'when changing cert_file' do
    it 'should recreate ssl config' do
      allow(File).to receive(':file?').and_return(true)
      expect(provider).to receive(:destroy)
      expect(provider).to receive(:create)
      provider.cert_file = '/tmp/blah.crt'
    end
  end

  context 'when changing key_file' do
    it 'should recreate ssl config' do
      allow(File).to receive(':file?').and_return(true)
      expect(provider).to receive(:destroy)
      expect(provider).to receive(:create)
      provider.key_file = '/tmp/blah.pem'
    end
  end

  context 'when changing ca_file' do
    it 'should recreate ssl config' do
      allow(File).to receive(':file?').and_return(true)
      expect(provider).to receive(:destroy)
      expect(provider).to receive(:create)
      provider.ca_file = '/tmp/blah.crt'
    end
  end

  context 'when creating with non-singleton name, system' do
    it 'should fail' do
      expect{described_class.new(Puppet::Type::Vs_ssl.new(
        {
          :name  => 'dummy',
          :ensure => :present})).create}.to raise_error(Puppet::Error)
    end
  end

end