Skip to content

Commit

Permalink
Merge 30939f2 into 4101df8
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrox committed Jun 25, 2018
2 parents 4101df8 + 30939f2 commit d71f2bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/facter/rabbitmq_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setcode do
if Facter::Util::Resolution.which('rabbitmqadmin')
rabbitmq_version = Facter::Core::Execution.execute('rabbitmqadmin --version 2>&1')
%r{^rabbitmqadmin ([\w\.]+)}.match(rabbitmq_version)[1]
%r{^rabbitmqadmin ([\w\.]+)}.match(rabbitmq_version).to_a[1]
end
end
end
9 changes: 9 additions & 0 deletions spec/unit/facter/util/fact_rabbitmq_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
expect(Facter.fact(:rabbitmq_version).value).to eq('3.6.0')
end
end
context 'with invalid value' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { true }
allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1') { 'rabbitmqadmin %%VSN%%' }
end
it do
expect(Facter.fact(:rabbitmq_version).value).to be_nil
end
end
context 'rabbitmqadmin is not in path' do
before do
allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { false }
Expand Down

0 comments on commit d71f2bc

Please sign in to comment.