Skip to content

Commit

Permalink
Add sid to application instance moved broadcast (#1586)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziosestito authored Jul 4, 2023
1 parent 6c5906b commit 2572501
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
7 changes: 5 additions & 2 deletions lib/trento/application/projectors/sap_system_projector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ defmodule Trento.SapSystemProjector do
new_host_id: new_host_id
},
_,
_
%{
application_instance: %ApplicationInstanceReadModel{sid: sid}
}
) do
TrentoWeb.Endpoint.broadcast(
@sap_systems_topic,
Expand All @@ -277,7 +279,8 @@ defmodule Trento.SapSystemProjector do
sap_system_id: sap_system_id,
instance_number: instance_number,
old_host_id: old_host_id,
new_host_id: new_host_id
new_host_id: new_host_id,
sid: sid
}
)
)
Expand Down
25 changes: 14 additions & 11 deletions test/trento/application/projectors/sap_system_projector_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ defmodule Trento.SapSystemProjectorTest do
test "should move the application instance when an ApplicationInstanceMoved is received" do
insert(:sap_system, id: sap_system_id = Faker.UUID.v4())

%{host_id: old_host_id, instance_number: instance_number} =
%{host_id: old_host_id, instance_number: instance_number, sid: sid} =
insert(:application_instance, sap_system_id: sap_system_id)

event = %ApplicationInstanceMoved{
Expand All @@ -169,7 +169,8 @@ defmodule Trento.SapSystemProjectorTest do
sap_system_id: ^sap_system_id,
instance_number: ^instance_number,
old_host_id: ^old_host_id,
new_host_id: ^new_host_id
new_host_id: ^new_host_id,
sid: ^sid
},
1000
)
Expand Down Expand Up @@ -253,15 +254,17 @@ defmodule Trento.SapSystemProjectorTest do

projection = Repo.get(SapSystemReadModel, sap_system_id)

assert_broadcast "sap_system_registered",
%{
db_host: ^new_db_host,
health: ^new_health,
id: ^sap_system_id,
sid: ^sid,
tenant: ^tenant
},
1000
assert_broadcast(
"sap_system_registered",
%{
db_host: ^new_db_host,
health: ^new_health,
id: ^sap_system_id,
sid: ^sid,
tenant: ^tenant
},
1000
)

assert nil == projection.deregistered_at
end
Expand Down

0 comments on commit 2572501

Please sign in to comment.