Skip to content

Commit

Permalink
Fixes #36954 - add cache status to ping output
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Nov 29, 2023
1 parent f4f4649 commit 5566f9e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/hammer_cli_foreman/ping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ class ForemanCommand < HammerCLIForeman::Command
field :active, _('Status')
field :duration_ms, _('Server Response')
end
field :cache, _('cache'), Fields::Label do
field :servers, _('servers'), Fields::Collection do
field :status, _('Status')
field :duration_ms, _('Server Response')
end
end
end
end

Expand Down
24 changes: 24 additions & 0 deletions test/functional/ping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@
assert_cmd(expected_result, result)
end

it 'includes cache status if foreman reports it' do
ping_results['results']['foreman']['cache'] = {
'servers' => [
{
'status' => 'ok',
'duration_ms' => 5
}
]
}
api_expects(:ping, :ping, 'Ping').returns(ping_results)

output = OutputMatcher.new(
[
'cache:',
' Status: ok',
' Server Response: 5'
]
)

expected_result = success_result(output)
result = run_cmd(cmd)
assert_cmd(expected_result, result)
end

it 'returns 1 if one of the services failed and shows unrecognized services' do
ping_results['results']['new_plugin'] = {
'services' => {
Expand Down

0 comments on commit 5566f9e

Please sign in to comment.