@@ -439,6 +439,55 @@ pub mod testing {
439
439
use crate :: event:: snapshot:: Location ;
440
440
use core:: sync:: atomic:: { AtomicU32 , Ordering } ;
441
441
use std:: sync:: Mutex ;
442
+ pub mod endpoint {
443
+ use super :: * ;
444
+ pub struct Subscriber {
445
+ location : Option < Location > ,
446
+ output : Mutex < Vec < String > > ,
447
+ }
448
+ impl Drop for Subscriber {
449
+ fn drop ( & mut self ) {
450
+ if std:: thread:: panicking ( ) {
451
+ return ;
452
+ }
453
+ if let Some ( location) = self . location . as_ref ( ) {
454
+ location. snapshot_log ( & self . output . lock ( ) . unwrap ( ) ) ;
455
+ }
456
+ }
457
+ }
458
+ impl Subscriber {
459
+ #[ doc = r" Creates a subscriber with snapshot assertions enabled" ]
460
+ #[ track_caller]
461
+ pub fn snapshot ( ) -> Self {
462
+ let mut sub = Self :: no_snapshot ( ) ;
463
+ sub. location = Location :: from_thread_name ( ) ;
464
+ sub
465
+ }
466
+ #[ doc = r" Creates a subscriber with snapshot assertions enabled" ]
467
+ #[ track_caller]
468
+ pub fn named_snapshot < Name : core:: fmt:: Display > ( name : Name ) -> Self {
469
+ let mut sub = Self :: no_snapshot ( ) ;
470
+ sub. location = Some ( Location :: new ( name) ) ;
471
+ sub
472
+ }
473
+ #[ doc = r" Creates a subscriber with snapshot assertions disabled" ]
474
+ pub fn no_snapshot ( ) -> Self {
475
+ Self {
476
+ location : None ,
477
+ output : Default :: default ( ) ,
478
+ }
479
+ }
480
+ }
481
+ impl super :: super :: Subscriber for Subscriber {
482
+ type ConnectionContext = ( ) ;
483
+ fn create_connection_context (
484
+ & self ,
485
+ _meta : & api:: ConnectionMeta ,
486
+ _info : & api:: ConnectionInfo ,
487
+ ) -> Self :: ConnectionContext {
488
+ }
489
+ }
490
+ }
442
491
#[ derive( Clone , Debug ) ]
443
492
pub struct Subscriber {
444
493
location : Option < Location > ,
0 commit comments