Skip to content

Commit 865674f

Browse files
authored
Return conn instead of chan from connection fun (#52)
* Return conn instead of chan from `connection` fun Might break some code that depends on this incorrect behavior. * Fixed tests to assume connection
1 parent d0243ea commit 865674f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/protocol.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ function connection(; virtualhost="/", host="localhost", port=AMQPClient.AMQP_DE
672672
end
673673
throw(AMQPClientException(error_message))
674674
end
675-
chan
675+
conn
676676
end
677677

678678
function connection(f; kwargs...)

test/test_coverage.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ function runtests(;virtualhost="/", host="localhost", port=AMQPClient.AMQP_DEFAU
2525
# open a connection
2626
@info("opening connection")
2727
connection(;virtualhost=virtualhost, host=host, port=port, amqps=amqps, auth_params=auth_params, send_queue_size=512, keepalive=keepalive, heartbeat=heartbeat) do conn
28-
@test conn.conn.sendq.sz_max == 512
28+
# Issue #51
29+
@test isa(conn, AMQPClient.Connection)
30+
31+
@test conn.sendq.sz_max == 512
2932

3033
# open a channel
3134
@info("opening channel")
3235
channel(conn, AMQPClient.UNUSED_CHANNEL, true) do chan1
3336
@test chan1.id == 1
34-
@test conn.conn.sendq.sz_max == 512
37+
@test conn.sendq.sz_max == 512
3538

3639
# test default exchange names
3740
@test default_exchange_name() == ""
@@ -168,8 +171,8 @@ function runtests(;virtualhost="/", host="localhost", port=AMQPClient.AMQP_DEFAU
168171
@test tx_rollback(chan1)
169172

170173
# test heartbeats
171-
if 120 >= conn.conn.heartbeat > 0
172-
c = conn.conn
174+
if 120 >= conn.heartbeat > 0
175+
c = conn
173176
@info("testing heartbeats (waiting $(3*c.heartbeat) secs)...")
174177
ts1 = c.heartbeat_time_server
175178
tc1 = c.heartbeat_time_client
@@ -180,10 +183,10 @@ function runtests(;virtualhost="/", host="localhost", port=AMQPClient.AMQP_DEFAU
180183
end
181184
@test c.heartbeat_time_server > ts1
182185
@test c.heartbeat_time_client > tc1
183-
elseif conn.conn.heartbeat == 0
186+
elseif conn.heartbeat == 0
184187
@info("heartbeat disabled")
185188
else
186-
@info("not testing heartbeats (wait too long at $(3*conn.conn.heartbeat) secs)")
189+
@info("not testing heartbeats (wait too long at $(3*conn.heartbeat) secs)")
187190
end
188191

189192
@info("closing down")

0 commit comments

Comments
 (0)