File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
lib/async/container/supervisor Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def connect
4545
4646 # Run the client in a loop, reconnecting if necessary.
4747 def run
48- Async do
48+ Async ( annotation : "Supervisor Client" , transient : true ) do
4949 loop do
5050 connection = connect!
5151
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ # Released under the MIT License.
4+ # Copyright, 2025, by Samuel Williams.
5+
6+ require "async/container/supervisor/a_server"
7+ require "sus/fixtures/console/captured_logger"
8+
9+ describe Async ::Container ::Supervisor ::Client do
10+ include Async ::Container ::Supervisor ::AServer
11+ include Sus ::Fixtures ::Console ::CapturedLogger
12+
13+ let ( :client ) { subject . new ( endpoint : endpoint ) }
14+
15+ with "#connect" do
16+ it "can connect to a server" do
17+ client . connect do |connection |
18+ expect ( connection ) . to be_a ( Async ::Container ::Supervisor ::Connection )
19+ end
20+ end
21+ end
22+
23+ with "#run" do
24+ it "can run the client" do
25+ connected = Async ::Promise . new
26+ expect ( client ) . to receive ( :connected! ) { |connection | connected . resolve ( true ) }
27+
28+ client_task = client . run
29+
30+ expect ( client_task ) . to be ( :transient? )
31+ expect ( connected . wait ) . to be == true
32+
33+ client_task . stop
34+ end
35+ end
36+ end
You can’t perform that action at this time.
0 commit comments