11use std:: env:: temp_dir;
22
33use crate :: auth_file_watcher:: AuthFileWatcher ;
4- use crate :: test_utils:: test_file:: { create_log_line, rename_file , TestFile } ;
4+ use crate :: test_utils:: test_file:: { create_log_line, TestFile } ;
55
66const TEST_MESSAGES : [ & str ; 6 ] = [
77 "workstation sudo: pam_unix(sudo:auth): authentication failure; logname=john uid=1000 euid=0 tty=/dev/pts/7 ruser=john rhost= user=john" ,
@@ -83,7 +83,6 @@ fn when_new_file_was_created_after_old_was_deleted_then_changes_in_new_file_are_
8383
8484 file. create ( ) ;
8585 expect_no_update_callback_call ( & mut auth_file_watcher) ;
86-
8786 expect_update_callback_is_called_when_file_is_modified ( & mut file, & mut auth_file_watcher) ;
8887}
8988
@@ -96,17 +95,18 @@ fn expect_no_update_callback_call(auth_file_watcher: &mut AuthFileWatcher) {
9695#[ test]
9796fn when_new_file_has_been_created_after_old_was_renamed_then_changes_in_new_file_are_monitored ( ) {
9897 let mut file = TestFile :: with_unique_name ( ) ;
98+ let filepath = String :: from ( file. path ( ) ) ;
9999 let mut auth_file_watcher =
100- AuthFileWatcher :: new ( file . path ( ) ) . expect ( "Error creating AuthFileWatcher" ) ;
100+ AuthFileWatcher :: new ( & filepath ) . expect ( "Error creating AuthFileWatcher" ) ;
101101 expect_no_update_callback_call ( & mut auth_file_watcher) ;
102102
103- rename_file ( file. path ( ) , "auth-monitor-test.bak" ) ;
103+ let new_filepath = format ! ( "{}.bak" , file. path( ) ) ;
104+ file. rename ( & new_filepath) ;
104105 expect_no_update_callback_call ( & mut auth_file_watcher) ;
105106
106- file . create ( ) ;
107+ let mut new_file = TestFile :: new ( & filepath ) ;
107108 expect_no_update_callback_call ( & mut auth_file_watcher) ;
108-
109- expect_update_callback_is_called_when_file_is_modified ( & mut file, & mut auth_file_watcher) ;
109+ expect_update_callback_is_called_when_file_is_modified ( & mut new_file, & mut auth_file_watcher) ;
110110}
111111
112112#[ test]
@@ -118,6 +118,5 @@ fn when_monitored_file_has_been_truncated_then_changes_are_still_monitored() {
118118
119119 file. truncate ( ) ;
120120 expect_no_update_callback_call ( & mut auth_file_watcher) ;
121-
122121 expect_update_callback_is_called_when_file_is_modified ( & mut file, & mut auth_file_watcher) ;
123122}
0 commit comments