Skip to content

Commit

Permalink
Add host checks selection test
Browse files Browse the repository at this point in the history
  • Loading branch information
EMaksy authored and nelsonkopliku committed Jun 16, 2023
1 parent 9a0a8b7 commit 5f1e790
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions test/trento/domain/host/host_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule Trento.HostTest do
alias Trento.Domain.Commands.{
RegisterHost,
RollUpHost,
SelectHostChecks,
UpdateHeartbeat,
UpdateProvider,
UpdateSlesSubscriptions
Expand All @@ -14,6 +15,7 @@ defmodule Trento.HostTest do
alias Trento.Domain.Events.{
HeartbeatFailed,
HeartbeatSucceded,
HostChecksSelected,
HostDetailsUpdated,
HostRegistered,
HostRolledUp,
Expand Down Expand Up @@ -154,6 +156,33 @@ defmodule Trento.HostTest do
end
end

describe "host checks selection" do
test "should select desired checks for host" do
host_id = Faker.UUID.v4()
selected_host_checks = Enum.map(0..4, fn _ -> Faker.Cat.name() end)
host_registered_event = build(:host_registered_event, host_id: host_id)

assert_events_and_state(
host_registered_event,
SelectHostChecks.new!(%{
host_id: host_id,
checks: selected_host_checks
}),
[
%HostChecksSelected{
host_id: host_id,
checks: selected_host_checks
}
],
fn host ->
assert %Host{
selected_checks: ^selected_host_checks
} = host
end
)
end
end

describe "heartbeat" do
test "should emit an HeartbeatSucceded event if the Host never received an heartbeat already" do
host_id = Faker.UUID.v4()
Expand Down Expand Up @@ -526,11 +555,6 @@ defmodule Trento.HostTest do
end
end

describe "checks execution" do
test "should select desired checks" do
end
end

describe "rollup" do
test "should not accept a rollup command if a host was not registered yet" do
assert_error(
Expand Down

0 comments on commit 5f1e790

Please sign in to comment.