Skip to content

Commit d644c58

Browse files
committed
Fix subscribe_bind test
Signed-off-by: Waldemar Quevedo <[email protected]>
1 parent 339a8e1 commit d644c58

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tests/test_js.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,28 +876,40 @@ async def test_subscribe_bind(self):
876876
consumer_name = "alice"
877877
await js.add_stream(name=stream_name, subjects=[subject_name])
878878

879+
# Create the consumer and assign a deliver subject which
880+
# will then be picked up on bind.
881+
inbox = nc.new_inbox()
882+
config = nats.js.api.ConsumerConfig(deliver_subject=inbox)
879883
consumer_info = await js.add_consumer(
880884
stream=stream_name,
885+
config=config,
881886
durable_name=consumer_name,
882887
)
883888
assert consumer_info.stream_name == stream_name
884889
assert consumer_info.name == consumer_name
885890
assert consumer_info.config.durable_name == consumer_name
886891

892+
# Subscribe using the deliver subject that was chosen before.
887893
sub = await js.subscribe_bind(
888894
stream=consumer_info.stream_name,
889895
consumer=consumer_info.name,
890896
config=consumer_info.config,
891897
)
892-
assert sub.queue == ""
893-
assert sub.pending_msgs == 0
894-
895898
for i in range(10):
896899
await js.publish(subject_name, f'Hello World {i}'.encode())
897900

898-
await sub.next_msg(timeout=2)
901+
msgs = []
902+
for i in range(0, 10):
903+
msg = await sub.next_msg()
904+
msgs.append(msg)
905+
await msg.ack()
906+
assert len(msgs) == 10
899907
assert sub.pending_msgs == 0
900908

909+
info = await sub.consumer_info()
910+
assert info.num_ack_pending == 0
911+
assert info.num_pending == 0
912+
901913

902914
class AckPolicyTest(SingleJetStreamServerTestCase):
903915

0 commit comments

Comments
 (0)