File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -590,4 +590,34 @@ mod tests {
590590 let err = result. unwrap_err ( ) ;
591591 assert ! ( err. to_string( ) . contains( "references non-existent trigger" ) ) ;
592592 }
593+
594+ #[ test]
595+ fn test_load_from_path_error_handling ( ) {
596+ // Create a temporary directory for testing
597+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
598+ let invalid_path = temp_dir. path ( ) . join ( "non_existent_monitor.json" ) ;
599+
600+ // Create a repository instance
601+ let repository =
602+ MonitorRepository :: < NetworkRepository , TriggerRepository > :: new_with_monitors (
603+ HashMap :: new ( ) ,
604+ ) ;
605+
606+ // Attempt to load from non-existent path
607+ let result = repository. load_from_path ( Some ( & invalid_path) , None , None ) ;
608+
609+ // Verify error handling
610+ assert ! ( result. is_err( ) ) ;
611+ let err = result. unwrap_err ( ) ;
612+ match err {
613+ RepositoryError :: LoadError ( message) => {
614+ assert ! ( message. to_string( ) . contains( "Failed to load monitors" ) ) ;
615+ // Verify the error contains the path in its metadata
616+ assert ! ( message
617+ . to_string( )
618+ . contains( & invalid_path. display( ) . to_string( ) ) ) ;
619+ }
620+ _ => panic ! ( "Expected RepositoryError::LoadError" ) ,
621+ }
622+ }
593623}
You can’t perform that action at this time.
0 commit comments