Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update regexp for rabbitmq_nodename fact #545

Merged
merged 1 commit into from
Jun 29, 2017
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
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