Skip to content

Commit 80e7c1c

Browse files
committed
Fix test.
1 parent 395e1af commit 80e7c1c

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

fixtures/async/container/supervisor/a_server.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@
1212
module Async
1313
module Container
1414
module Supervisor
15+
class RegistrationMonitor
16+
def initialize
17+
@registrations = []
18+
end
19+
20+
attr :registrations
21+
22+
def run
23+
end
24+
25+
def register(connection)
26+
@registrations << connection
27+
end
28+
29+
def remove(connection)
30+
@registrations.delete(connection)
31+
end
32+
end
33+
1534
AServer = Sus::Shared("a server") do
1635
include Sus::Fixtures::Async::SchedulerContext
1736

@@ -25,7 +44,9 @@ def around(&block)
2544
end
2645
end
2746

28-
let(:server) {Async::Container::Supervisor::Server.new(@bound_endpoint)}
47+
let(:registration_monitor) {RegistrationMonitor.new}
48+
let(:monitors) {[registration_monitor]}
49+
let(:server) {Async::Container::Supervisor::Server.new(@bound_endpoint, monitors: monitors)}
2950

3051
before do
3152
@bound_endpoint = endpoint.bound

lib/async/container/supervisor/server.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def run
6969

7070
task.children&.each(&:wait)
7171
ensure
72-
Console.info(self, "Stopping...")
7372
task.stop
7473
end
7574
end

lib/async/container/supervisor/service.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Copyright, 2025, by Samuel Williams.
55

66
require "async"
7+
require "async/service/generic"
78
require "io/endpoint/bound_endpoint"
89

910
module Async

test/async/container/supervisor.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ def to_json(...)
2323
client = Async::Container::Supervisor::Client.new(instance, endpoint)
2424
connection = client.connect
2525

26-
sleep(0.001) until server.registered.any?
26+
sleep(0.001) until registration_monitor.registrations.any?
2727

28-
registration = server.registered.first
29-
expect(registration.last).to have_keys(
30-
action: be == "register",
31-
instance: be == instance.as_json,
28+
registration = registration_monitor.registrations.first
29+
expect(registration.state).to have_keys(
30+
process_id: be == ::Process.pid
3231
)
3332
end
3433
end

0 commit comments

Comments
 (0)