Skip to content

Commit

Permalink
Merge pull request #1 from wyardley/676
Browse files Browse the repository at this point in the history
Resolve test failures
  • Loading branch information
fatmcgav authored Jan 11, 2018
2 parents 57cd64a + 9eb70cd commit bf7eec7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions lib/puppet/provider/rabbitmq_policy/rabbitmqctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ def self.policies(vhost, name)
# / ha-all .* all {"ha-mode":"all","ha-sync-mode":"automatic"} 0 << This is for RabbitMQ v >= 3.7.0
if Puppet::Util::Package.versioncmp(rabbitmq_version, '3.7') >= 0
regex = %r{^(\S+)\s+(\S+)\s+(\S+)\s+(all|exchanges|queues)?\s+(\S+)\s+(\d+)$}
applyto_index, pattern_index = 4, 3
applyto_index = 4
pattern_index = 3
else
regex = %r{^(\S+)\s+(\S+)\s+(all|exchanges|queues)?\s*(\S+)\s+(\S+)\s+(\d+)$}
applyto_index, pattern_index = 3, 4
applyto_index = 3
pattern_index = 4
end

policy_list.split(%r{\n}).each do |line|
Expand Down
14 changes: 7 additions & 7 deletions spec/unit/puppet/provider/rabbitmq_policy/rabbitmqctl_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
require 'spec_helper'

describe Puppet::Type.type(:rabbitmq_policy).provider(:rabbitmqctl) do
provider_class = Puppet::Type.type(:rabbitmq_policy).provider(:rabbitmqctl)
describe provider_class do
let(:resource) do
Puppet::Type.type(:rabbitmq_policy).new(
name: 'ha-all@/',
pattern: '.*',
definition: {
'ha-mode' => 'all'
},
provider: described_class.name
}
)
end
let(:provider) { resource.provider }
let(:provider) { provider_class.new(resource) }

after do
described_class.instance_variable_set(:@policies, nil)
Expand Down Expand Up @@ -47,7 +47,7 @@

context 'with RabbitMQ version >=3.7.0' do
it 'matches policies from list' do
provider.class.expects(:rabbitmqctl).with('-q', 'status').returns '{rabbit,"RabbitMQ","3.7.0"}'
provider.class.expects(:rabbitmq_version).returns '3.7.0'
provider.class.expects(:rabbitmqctl).with('list_policies', '-q', '-p', '/').returns <<-EOT
/ ha-all .* all {"ha-mode":"all","ha-sync-mode":"automatic"} 0
/ test .* exchanges {"ha-mode":"all"} 0
Expand All @@ -64,7 +64,7 @@

context 'with RabbitMQ version >=3.2.0 and < 3.7.0' do
it 'matches policies from list' do
provider.class.expects(:rabbitmqctl).with('-q', 'status').returns '{rabbit,"RabbitMQ","3.6.9"}'
provider.class.expects(:rabbitmq_version).returns '3.6.9'
provider.class.expects(:rabbitmqctl).with('list_policies', '-q', '-p', '/').returns <<-EOT
/ ha-all all .* {"ha-mode":"all","ha-sync-mode":"automatic"} 0
/ test exchanges .* {"ha-mode":"all"} 0
Expand All @@ -81,7 +81,7 @@

context 'with RabbitMQ version <3.2.0' do
it 'matches policies from list (<3.2.0)' do
provider.class.expects(:rabbitmqctl).with('-q', 'status').returns '{rabbit,"RabbitMQ","3.1.5"}'
provider.class.expects(:rabbitmq_version).returns '3.1.5'
provider.class.expects(:rabbitmqctl).with('list_policies', '-q', '-p', '/').returns <<-EOT
/ ha-all .* {"ha-mode":"all","ha-sync-mode":"automatic"} 0
/ test .* {"ha-mode":"all"} 0
Expand Down

0 comments on commit bf7eec7

Please sign in to comment.