async fn bail_calls_abort_on_highest_errored_feroxscan() {
        let (handles, _) = setup_requester_test(None).await;

        let scan_one = create_scan(handles.clone(), "http://one", 10, PolicyTrigger::Errors).await;
        let scan_two = create_scan(handles.clone(), "http://two", 14, PolicyTrigger::Errors).await;
        let scan_three =
            create_scan(handles.clone(), "http://three", 4, PolicyTrigger::Errors).await;
        let scan_four = create_scan(handles.clone(), "http://four", 7, PolicyTrigger::Errors).await;

        // set up a fake JoinHandle for the scan that's expected to have .abort called on it
        // the reason being if there's no task, the status is never updated, so can't be checked
        let dummy_task =
            tokio::spawn(async move { tokio::time::sleep(Duration::new(15, 0)).await });
        scan_two.set_task(dummy_task).await.unwrap();

        assert!(scan_one.is_active());
        assert!(scan_two.is_active());

        let scans = handles.ferox_scans().unwrap();
        assert_eq!(scans.get_active_scans().len(), 4);

        let req_clone = scan_two.clone();
        let requester = Requester {
            handles,
            seen_links: RwLock::new(HashSet::<String>::new()),
            tuning_lock: Mutex::new(0),
            ferox_scan: req_clone,
            target_url: "http://one/one/stuff.php".to_string(),
            rate_limiter: RwLock::new(None),
            policy_data: Default::default(),
        };

        requester.bail(PolicyTrigger::Errors).await.unwrap();
        assert_eq!(scans.get_active_scans().len(), 3);
        assert!(scan_one.is_active());
        assert!(scan_three.is_active());
        assert!(scan_four.is_active());
        assert!(!scan_two.is_active());
    }
/// bail should call abort on the scan with the most errors
bail should call abort on the scan with the most errors
bail should call abort on the scan with the most errors
async fn bail_calls_abort_on_highest_errored_feroxscan() {
        let (handles, _) = setup_requester_test(None).await;
        let scan_one = create_scan(handles.clone(), "http://one", 10, PolicyTrigger::Errors).await;
        let scan_two = create_scan(handles.clone(), "http://two", 14, PolicyTrigger::Errors).await;
        let scan_three =
            create_scan(handles.clone(), "http://three", 4, PolicyTrigger::Errors).await;
        let scan_four = create_scan(handles.clone(), "http://four", 7, PolicyTrigger::Errors).await;
        // set up a fake JoinHandle for the scan that's expected to have .abort called on it
        // the reason being if there's no task, the status is never updated, so can't be checked
        let dummy_task =
            tokio::spawn(async move { tokio::time::sleep(Duration::new(15, 0)).await });
        scan_two.set_task(dummy_task).await.unwrap();
        assert!(scan_one.is_active());
        assert!(scan_two.is_active());
        let scans = handles.ferox_scans().unwrap();
        assert_eq!(scans.get_active_scans().len(), 4);
        let req_clone = scan_two.clone();
        let requester = Requester {
            handles,
            seen_links: RwLock::new(HashSet::<String>::new()),
            tuning_lock: Mutex::new(0),
            ferox_scan: req_clone,
            target_url: "http://one/one/stuff.php".to_string(),
            rate_limiter: RwLock::new(None),
            policy_data: Default::default(),
        };
        requester.bail(PolicyTrigger::Errors).await.unwrap();
        assert_eq!(scans.get_active_scans().len(), 3);
        assert!(scan_one.is_active());
        assert!(scan_three.is_active());
        assert!(scan_four.is_active());
        assert!(!scan_two.is_active());
    }
async fn bail_calls_abort_on_highest_errored_feroxscan ( ) { let ( handles , _ ) = setup_requester_test ( None ) . await ; let scan_one = create_scan ( handles . clone ( ) , " " , 10 , PolicyTrigger :: Errors ) . await ; let scan_two = create_scan ( handles . clone ( ) , " " , 14 , PolicyTrigger :: Errors ) . await ; let scan_three = create_scan ( handles . clone ( ) , " " , 4 , PolicyTrigger :: Errors ) . await ; let scan_four = create_scan ( handles . clone ( ) , " " , 7 , PolicyTrigger :: Errors ) . await ; // set up a fake JoinHandle for the scan that's expected to have .abort called on it // the reason being if there's no task, the status is never updated, so can't be checked let dummy_task = tokio :: spawn ( async move { tokio :: time :: sleep ( Duration :: new ( 15 , 0 ) ) . await } ) ; scan_two . set_task ( dummy_task ) . await . unwrap ( ) ; assert ! ( scan_one is_active ( ) ) ; assert ! ( scan_two is_active ( ) ) ; let scans = handles . ferox_scans ( ) . unwrap ( ) ; assert_eq ! ( scans get_active_scans ( ) len ( ) 4 ) ; let req_clone = scan_two . clone ( ) ; let requester = Requester { handles , seen_links : RwLock :: new ( HashSet :: < String > :: new ( ) ) , tuning_lock : Mutex :: new ( 0 ) , ferox_scan : req_clone , target_url : " " . to_string ( ) , rate_limiter : RwLock :: new ( None ) , policy_data : Default :: default ( ) , } ; requester . bail ( PolicyTrigger :: Errors ) . await . unwrap ( ) ; assert_eq ! ( scans get_active_scans ( ) len ( ) 3 ) ; assert ! ( scan_one is_active ( ) ) ; assert ! ( scan_three is_active ( ) ) ; assert ! ( scan_four is_active ( ) ) ; assert ! ( scan_two is_active ( ) ) ; }
bail should call abort on the scan with the most errors
bail should call abort on the scan with the most errors