Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-05-18 22:27:55 UTC using RuboCop version 1.50.2.
# `rubocop --auto-gen-config --no-auto-gen-timestamp`
# using RuboCop version 1.50.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -16,6 +16,12 @@ RSpec/BeEq:
- 'spec/unit/puppet/provider/rabbitmq_vhost/rabbitmqctl_spec.rb'
- 'spec/unit/puppet/type/rabbitmq_user_permissions_spec.rb'

# Offense count: 185
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 3
RSpec/PendingWithoutReason:
Exclude:
Expand All @@ -30,3 +36,22 @@ RSpec/RepeatedExampleGroupBody:
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'spec/classes/rabbitmq_spec.rb'

# Offense count: 125
RSpec/StubbedMock:
Exclude:
- 'spec/unit/facter/util/fact_rabbitmq_clustername_spec.rb'
- 'spec/unit/facter/util/fact_rabbitmq_nodename_spec.rb'
- 'spec/unit/facter/util/fact_rabbitmq_plugins_dirs_spec.rb'
- 'spec/unit/facter/util/fact_rabbitmq_version_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_binding/rabbitmqadmin_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_cli_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_cluster/rabbitmqctl_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_exchange/rabbitmqadmin_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_parameter/rabbitmqctl_federation_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_parameter/rabbitmqctl_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_plugin/rabbitmqctl_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_policy/rabbitmqctl_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_queue/rabbitmqadmin_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_user_permissions/rabbitmqctl_spec.rb'
- 'spec/unit/puppet/provider/rabbitmq_vhost/rabbitmqctl_spec.rb'
5 changes: 0 additions & 5 deletions .sync.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
---
spec/spec_helper.rb:
facterdb_string_keys: true
mock_with: ':mocha'
spec_overrides: "require 'spec_helper_local'"
.puppet-lint.rc:
enabled_lint_checks:
- parameter_documentation
- parameter_types
Gemfile:
optional:
':test':
- gem: 'mocha'
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
group :test do
gem 'voxpupuli-test', '~> 11.0', :require => false
gem 'puppet_metadata', '~> 5.0', :require => false
gem 'mocha', :require => false
end

group :development do
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

RSpec.configure do |c|
c.facterdb_string_keys = true
c.mock_with :mocha
end

add_mocked_facts!
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/facter/util/fact_erl_ssl_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
describe 'erl_ssl_path' do
context 'with valid value' do
it do
Facter::Util::Resolution.expects(:which).with('erl').returns(true)
Facter::Core::Execution.expects(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell").returns('"/usr/lib64/erlang/lib/ssl-5.3.3/ebin"')
allow(Facter::Util::Resolution).to receive(:which).with('erl').and_return(true)
allow(Facter::Core::Execution).to receive(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell").and_return('"/usr/lib64/erlang/lib/ssl-5.3.3/ebin"')
expect(Facter.fact(:erl_ssl_path).value).to eq('/usr/lib64/erlang/lib/ssl-5.3.3/ebin')
end
end

context 'with error message' do
it do
Facter::Util::Resolution.expects(:which).with('erl').returns(true)
Facter::Core::Execution.expects(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell").returns('{error,bad_name}')
allow(Facter::Util::Resolution).to receive(:which).with('erl').and_return(true)
allow(Facter::Core::Execution).to receive(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell").and_return('{error,bad_name}')
expect(Facter.fact(:erl_ssl_path).value).to be_nil
end
end

context 'with erl not present' do
it do
Facter::Util::Resolution.expects(:which).with('erl').returns(false)
allow(Facter::Util::Resolution).to receive(:which).with('erl').and_return(false)
expect(Facter.fact(:erl_ssl_path).value).to be_nil
end
end
Expand Down
22 changes: 11 additions & 11 deletions spec/unit/facter/util/fact_rabbitmq_clustername_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@
describe 'rabbitmq_clusternam' do
context 'with value' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl -q cluster_status 2>&1').returns(' {cluster_name,<<"monty">>},')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl -q cluster_status 2>&1').and_return(' {cluster_name,<<"monty">>},')
expect(Facter.fact(:rabbitmq_clustername).value).to eq('monty')
end
end

context 'with dashes in hostname' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl -q cluster_status 2>&1').returns('Cluster name: rabbit-1')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl -q cluster_status 2>&1').and_return('Cluster name: rabbit-1')
expect(Facter.fact(:rabbitmq_clustername).value).to eq('rabbit-1')
end
end

context 'with dashes in clustername/hostname' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl -q cluster_status 2>&1').returns(' {cluster_name,<<"monty-python@rabbit-1">>},')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl -q cluster_status 2>&1').and_return(' {cluster_name,<<"monty-python@rabbit-1">>},')
expect(Facter.fact(:rabbitmq_clustername).value).to eq('monty-python@rabbit-1')
end
end

context 'with quotes around node name' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl -q cluster_status 2>&1').returns("monty\npython\nCluster name: 'monty@rabbit-1'\nend\nof\nfile")
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl -q cluster_status 2>&1').and_return("monty\npython\nCluster name: 'monty@rabbit-1'\nend\nof\nfile")
expect(Facter.fact(:rabbitmq_clustername).value).to eq("'monty@rabbit-1'")
end
end
Expand Down Expand Up @@ -63,15 +63,15 @@
- cookie hash: 6WdP0nl6d3HYqA5vTKMkIg==

EOS
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl -q cluster_status 2>&1').returns(error_string)
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl -q cluster_status 2>&1').and_return(error_string)
expect(Facter.fact(:rabbitmq_clustername).value).to be_nil
end
end

context 'rabbitmqctl is not in path' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(false)
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(false)
expect(Facter.fact(:rabbitmq_clustername).value).to be_nil
end
end
Expand Down
30 changes: 16 additions & 14 deletions spec/unit/facter/util/fact_rabbitmq_nodename_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,47 @@
require 'spec_helper'

describe Facter::Util::Fact do
before { Facter.clear }
before do
Facter.clear
end

describe 'rabbitmq_nodename' do
context 'with value' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit1 ...')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node monty@rabbit1 ...')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit1')
end
end

context 'with dashes in hostname' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1 ...')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node monty@rabbit-1 ...')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
end
end

context 'with dashes in nodename/hostname' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty-python@rabbit-1 ...')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node monty-python@rabbit-1 ...')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty-python@rabbit-1')
end
end

context 'with quotes around node name' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node \'monty@rabbit-1\' ...')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node \'monty@rabbit-1\' ...')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
end
end

context 'without trailing points' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node monty@rabbit-1')
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
end
end
Expand Down Expand Up @@ -69,15 +71,15 @@
- cookie hash: 6WdP0nl6d3HYqA5vTKMkIg==

EOS
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns(error_string)
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return(error_string)
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
end
end

context 'rabbitmqctl is not in path' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(false)
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(false)
expect(Facter.fact(:rabbitmq_nodename).value).to be_nil
end
end
Expand Down
14 changes: 8 additions & 6 deletions spec/unit/facter/util/fact_rabbitmq_plugins_dirs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@
require 'spec_helper'

describe Facter::Util::Fact do
before { Facter.clear }
before do
Facter.clear
end

describe 'rabbitmq_plugins_dirs' do
context 'with multiple plugins dirs' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with("rabbitmqctl eval 'application:get_env(rabbit, plugins_dir).'").returns('{ok,"/usr/lib/rabbitmq/plugins:/usr/lib/rabbitmq/lib/rabbitmq_server-3.7.10/plugins"}')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with("rabbitmqctl eval 'application:get_env(rabbit, plugins_dir).'").and_return('{ok,"/usr/lib/rabbitmq/plugins:/usr/lib/rabbitmq/lib/rabbitmq_server-3.7.10/plugins"}')
expect(Facter.fact(:rabbitmq_plugins_dirs).value).to contain_exactly('/usr/lib/rabbitmq/plugins', '/usr/lib/rabbitmq/lib/rabbitmq_server-3.7.10/plugins')
end
end

context 'with only 1 plugins dir' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.expects(:execute).with("rabbitmqctl eval 'application:get_env(rabbit, plugins_dir).'").returns('{ok,"/usr/lib/rabbitmq/lib/rabbitmq_server-0.0.0/plugins"}')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with("rabbitmqctl eval 'application:get_env(rabbit, plugins_dir).'").and_return('{ok,"/usr/lib/rabbitmq/lib/rabbitmq_server-0.0.0/plugins"}')
expect(Facter.fact(:rabbitmq_plugins_dirs).value).to contain_exactly('/usr/lib/rabbitmq/lib/rabbitmq_server-0.0.0/plugins')
end
end

context 'rabbitmqctl is not in path' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(false)
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(false)
expect(Facter.fact(:rabbitmq_plugins_dirs).value).to be_nil
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/facter/util/fact_rabbitmq_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
describe 'rabbitmq_version' do
context 'with value' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqadmin').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqadmin --version 2>&1').returns('rabbitmqadmin 3.6.0')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1').and_return('rabbitmqadmin 3.6.0')
expect(Facter.fact(:rabbitmq_version).value).to eq('3.6.0')
end
end

context 'with invalid value' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqadmin').returns(true)
Facter::Core::Execution.expects(:execute).with('rabbitmqadmin --version 2>&1').returns('rabbitmqadmin %%VSN%%')
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin').and_return(true)
expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1').and_return('rabbitmqadmin %%VSN%%')
expect(Facter.fact(:rabbitmq_version).value).to be_nil
end
end

context 'rabbitmqadmin is not in path' do
it do
Facter::Util::Resolution.expects(:which).with('rabbitmqadmin').returns(false)
expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin').and_return(false)
expect(Facter.fact(:rabbitmq_version).value).to be_nil
end
end
Expand Down
Loading
Loading