File: rabbitmqctl_spec.rb

package info (click to toggle)
puppet-module-puppetlabs-rabbitmq 8.5.0-10
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,192 kB
  • sloc: ruby: 5,227; sh: 10; makefile: 4
file content (43 lines) | stat: -rw-r--r-- 1,114 bytes parent folder | download | duplicates (4)
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
require 'spec_helper'

provider_class = Puppet::Type.type(:rabbitmq_vhost).provider(:rabbitmqctl)
describe provider_class do
  let(:resource) do
    Puppet::Type::Rabbitmq_vhost.new(
      name: 'foo'
    )
  end
  let(:provider) { provider_class.new(resource) }

  it 'matches vhost names' do
    provider.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT
Listing vhosts ...
foo
...done.
EOT
    expect(provider.exists?).to eq(true)
  end
  it 'does not match if no vhosts on system' do
    provider.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT
Listing vhosts ...
...done.
EOT
    expect(provider.exists?).to eq(false)
  end
  it 'does not match if no matching vhosts on system' do
    provider.expects(:rabbitmqctl_list).with('vhosts').returns <<-EOT
Listing vhosts ...
fooey
...done.
EOT
    expect(provider.exists?).to eq(false)
  end
  it 'calls rabbitmqctl to create' do
    provider.expects(:rabbitmqctl).with('add_vhost', 'foo')
    provider.create
  end
  it 'calls rabbitmqctl to create' do
    provider.expects(:rabbitmqctl).with('delete_vhost', 'foo')
    provider.destroy
  end
end