Skip to content

Commit

Permalink
Merge pull request voxpupuli#545 from SergK/update_rabbitmq_nodename_…
Browse files Browse the repository at this point in the history
…regexp

Update regexp for rabbitmq_nodename fact
  • Loading branch information
hunner committed Jun 29, 2017
2 parents 51f1f53 + 21de346 commit 96ee3df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/facter/rabbitmq_nodename.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setcode do
if Facter::Core::Execution.which('rabbitmqctl')
rabbitmq_nodename = Facter::Core::Execution.execute('rabbitmqctl status 2>&1')
%r{^Status of node '?([\w\.]+@[\w\.\-]+)'? \.+$}.match(rabbitmq_nodename)[1]
%r{^Status of node '?([\w\.]+@[\w\.\-]+)'?}.match(rabbitmq_nodename)[1]
end
end
end
11 changes: 11 additions & 0 deletions spec/unit/rabbitmq_nodename_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,16 @@
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
}
end

context 'without trailing points' do
before :each do
Facter::Core::Execution.stubs(:which).with('rabbitmqctl').returns(true)
Facter::Core::Execution.stubs(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1')
end
it {
expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
}
end

end
end

0 comments on commit 96ee3df

Please sign in to comment.