//  Test `watch_annotations` will shutdown the client connection if a second
//  `watch_annotations` request is made before the previous request completes for the same client.
Test `watch_annotations` will shutdown the client connection if a second
`watch_annotations` request is made before the previous request completes for the same client.
Test ` watch_annotations ` will shutdown the client connection if a second ` watch_annotations ` request is made before the previous request completes for the same client .
async fn watch_annotations_duplicate_requests() -> Result<(), anyhow::Error> {
        let holder = Arc::new(Mutex::new(AnnotationHolder::new()));
        let mut watch_subscriber = holder.lock().unwrap().new_watch_subscriber();
        let (proxy, mut stream) =
            create_proxy_and_stream::<felement::AnnotationControllerMarker>().unwrap();
        // Make the initial request, so that the next one will hang.
        let annotations = proxy.watch_annotations();
        let result = handle_one_request(holder.clone(), &mut watch_subscriber, &mut stream);
        let (_, result) = fasync::futures::join!(annotations, result);
        assert!(result.is_ok());
        // Make a request to wait for updates
        let proxy_clone = proxy.clone();
        fasync::Task::spawn(async move {
            let _ = proxy_clone.watch_annotations().await;
        })
        .detach();
        let result = handle_one_request(holder.clone(), &mut watch_subscriber, &mut stream).await;
        assert!(result.is_ok());
        // A second request made before the previous completes errors and the connection gets shutdown
        let proxy_clone = proxy.clone();
        fasync::Task::spawn(async move {
            let _ = proxy_clone.watch_annotations().await;
        })
        .detach();
        let result = handle_one_request(holder.clone(), &mut watch_subscriber, &mut stream).await;
        assert_eq!(result, Err(AnnotationError::Watch(HangingGetServerError::MultipleObservers)));
        assert!(stream.next().await.is_none());
        assert!(stream.is_terminated());
        Ok(())
    }
async fn watch_annotations_duplicate_requests ( ) -> Result < ( ) , anyhow :: Error > { let holder = Arc :: new ( Mutex :: new ( AnnotationHolder :: new ( ) ) ) ; let mut watch_subscriber = holder . lock ( ) . unwrap ( ) . new_watch_subscriber ( ) ; let ( proxy , mut stream ) = create_proxy_and_stream :: < felement :: AnnotationControllerMarker > ( ) . unwrap ( ) ; // Make the initial request, so that the next one will hang. let annotations = proxy . watch_annotations ( ) ; let result = handle_one_request ( holder . clone ( ) , & mut watch_subscriber , & mut stream ) ; let ( _ , result ) = fasync :: futures :: join ! ( annotations result ) ; assert ! ( result is_ok ( ) ) ; // Make a request to wait for updates let proxy_clone = proxy . clone ( ) ; fasync :: Task :: spawn ( async move { let _ = proxy_clone . watch_annotations ( ) . await ; } ) . detach ( ) ; let result = handle_one_request ( holder . clone ( ) , & mut watch_subscriber , & mut stream ) . await ; assert ! ( result is_ok ( ) ) ; // A second request made before the previous completes errors and the connection gets shutdown let proxy_clone = proxy . clone ( ) ; fasync :: Task :: spawn ( async move { let _ = proxy_clone . watch_annotations ( ) . await ; } ) . detach ( ) ; let result = handle_one_request ( holder . clone ( ) , & mut watch_subscriber , & mut stream ) . await ; assert_eq ! ( result Err ( AnnotationError Watch ( HangingGetServerError MultipleObservers ) ) ) ; assert ! ( stream next ( ) await is_none ( ) ) ; assert ! ( stream is_terminated ( ) ) ; Ok ( ( ) ) }
Test `watch_annotations` will shutdown the client connection if a second
`watch_annotations` request is made before the previous request completes for the same client.
Test ` watch_annotations ` will shutdown the client connection if a second ` watch_annotations ` request is made before the previous request completes for the same client .