Skip to content

Commit

Permalink
Dispatch unknown health on batch auth error
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Apr 22, 2024
1 parent 4201498 commit 7fcfbb2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/trento/software_updates/discovery.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,16 @@ defmodule Trento.SoftwareUpdates.Discovery do
end
end

defp discover_host_software_updates(_, _, {:error, error}),
do: {:error, error}
defp discover_host_software_updates(host_id, _, {:error, error}) do
commanded().dispatch(
CompleteSoftwareUpdatesDiscovery.new!(%{
host_id: host_id,
health: SoftwareUpdatesHealth.unknown()
})
)

{:error, error}
end

defp discover_host_software_updates(host_id, fully_qualified_domain_name, _),
do: discover_host_software_updates(host_id, fully_qualified_domain_name)
Expand Down
19 changes: 19 additions & 0 deletions test/trento/software_updates/discovery_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,25 @@ defmodule Trento.SoftwareUpdates.DiscoveryTest do

[%{id: host_id1}, %{id: host_id2}] = insert_list(2, :host)

expect(
Trento.Commanded.Mock,
:dispatch,
2,
fn
%CompleteSoftwareUpdatesDiscovery{
host_id: ^host_id1,
health: SoftwareUpdatesHealth.unknown()
} ->
:ok

%CompleteSoftwareUpdatesDiscovery{
host_id: ^host_id2,
health: SoftwareUpdatesHealth.unknown()
} ->
:ok
end
)

{:ok, {[], errored_discoveries}} = Discovery.discover_software_updates()

Enum.each([host_id1, host_id2], fn host_id ->
Expand Down

0 comments on commit 7fcfbb2

Please sign in to comment.