@@ -171,6 +171,7 @@ impl Default for MockJetStreamContext {
171171
172172impl JetStreamContext for MockJetStreamContext {
173173 type Error = MockError ;
174+ type Stream = ( ) ;
174175
175176 async fn get_or_create_stream < S : Into < stream:: Config > + Send > (
176177 & self ,
@@ -254,13 +255,14 @@ impl Default for MockJetStreamPublisher {
254255
255256impl JetStreamPublisher for MockJetStreamPublisher {
256257 type PublishError = MockError ;
258+ type AckFuture = std:: future:: Ready < Result < PublishAck , MockError > > ;
257259
258- async fn js_publish_with_headers < S : ToSubject + Send > (
260+ async fn publish_with_headers < S : ToSubject + Send > (
259261 & self ,
260262 subject : S ,
261263 headers : HeaderMap ,
262264 payload : Bytes ,
263- ) -> Result < PublishAck , MockError > {
265+ ) -> Result < Self :: AckFuture , MockError > {
264266 let subject = subject. to_subject ( ) . to_string ( ) ;
265267 let should_fail = {
266268 let mut count = self . publish_fail_count . lock ( ) . unwrap ( ) ;
@@ -288,13 +290,13 @@ impl JetStreamPublisher for MockJetStreamPublisher {
288290 current
289291 } ;
290292
291- Ok ( PublishAck {
293+ Ok ( std :: future :: ready ( Ok ( PublishAck {
292294 stream : "mock-stream" . to_string ( ) ,
293295 sequence : seq,
294296 domain : String :: new ( ) ,
295297 duplicate : false ,
296298 value : None ,
297- } )
299+ } ) ) )
298300 }
299301}
300302
@@ -478,12 +480,14 @@ mod tests {
478480 async fn mock_publisher_records_publishes ( ) {
479481 let pub_mock = MockJetStreamPublisher :: new ( ) ;
480482 let ack = pub_mock
481- . js_publish_with_headers (
483+ . publish_with_headers (
482484 "test.subject" . to_string ( ) ,
483485 HeaderMap :: new ( ) ,
484486 Bytes :: from ( "hello" ) ,
485487 )
486488 . await
489+ . unwrap ( )
490+ . await
487491 . unwrap ( ) ;
488492 assert_eq ! ( ack. sequence, 1 ) ;
489493 assert_eq ! ( pub_mock. published_subjects( ) , vec![ "test.subject" ] ) ;
@@ -494,11 +498,15 @@ mod tests {
494498 async fn mock_publisher_increments_sequence ( ) {
495499 let pub_mock = MockJetStreamPublisher :: new ( ) ;
496500 let ack1 = pub_mock
497- . js_publish_with_headers ( "a" . to_string ( ) , HeaderMap :: new ( ) , Bytes :: new ( ) )
501+ . publish_with_headers ( "a" . to_string ( ) , HeaderMap :: new ( ) , Bytes :: new ( ) )
502+ . await
503+ . unwrap ( )
498504 . await
499505 . unwrap ( ) ;
500506 let ack2 = pub_mock
501- . js_publish_with_headers ( "b" . to_string ( ) , HeaderMap :: new ( ) , Bytes :: new ( ) )
507+ . publish_with_headers ( "b" . to_string ( ) , HeaderMap :: new ( ) , Bytes :: new ( ) )
508+ . await
509+ . unwrap ( )
502510 . await
503511 . unwrap ( ) ;
504512 assert_eq ! ( ack1. sequence, 1 ) ;
@@ -510,12 +518,12 @@ mod tests {
510518 let pub_mock = MockJetStreamPublisher :: new ( ) ;
511519 pub_mock. fail_next_js_publish ( ) ;
512520 let result = pub_mock
513- . js_publish_with_headers ( "test" . to_string ( ) , HeaderMap :: new ( ) , Bytes :: new ( ) )
521+ . publish_with_headers ( "test" . to_string ( ) , HeaderMap :: new ( ) , Bytes :: new ( ) )
514522 . await ;
515523 assert ! ( result. is_err( ) ) ;
516524
517525 let result = pub_mock
518- . js_publish_with_headers ( "test" . to_string ( ) , HeaderMap :: new ( ) , Bytes :: new ( ) )
526+ . publish_with_headers ( "test" . to_string ( ) , HeaderMap :: new ( ) , Bytes :: new ( ) )
519527 . await ;
520528 assert ! ( result. is_ok( ) ) ;
521529 }
@@ -589,19 +597,21 @@ mod tests {
589597 pub_mock. fail_js_publish_count ( 2 ) ;
590598 assert ! (
591599 pub_mock
592- . js_publish_with_headers ( "a" . to_string( ) , HeaderMap :: new( ) , Bytes :: new( ) )
600+ . publish_with_headers ( "a" . to_string( ) , HeaderMap :: new( ) , Bytes :: new( ) )
593601 . await
594602 . is_err( )
595603 ) ;
596604 assert ! (
597605 pub_mock
598- . js_publish_with_headers ( "b" . to_string( ) , HeaderMap :: new( ) , Bytes :: new( ) )
606+ . publish_with_headers ( "b" . to_string( ) , HeaderMap :: new( ) , Bytes :: new( ) )
599607 . await
600608 . is_err( )
601609 ) ;
602610 assert ! (
603611 pub_mock
604- . js_publish_with_headers( "c" . to_string( ) , HeaderMap :: new( ) , Bytes :: new( ) )
612+ . publish_with_headers( "c" . to_string( ) , HeaderMap :: new( ) , Bytes :: new( ) )
613+ . await
614+ . unwrap( )
605615 . await
606616 . is_ok( )
607617 ) ;
0 commit comments