File tree Expand file tree Collapse file tree 2 files changed +13
-14
lines changed
Expand file tree Collapse file tree 2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change 11use std:: env:: temp_dir;
2- use std:: fs:: rename;
3- use std:: path:: Path ;
42
53use chrono:: Local ;
64
75use crate :: auth_file_watcher:: AuthFileWatcher ;
8- use crate :: test_utils:: test_file:: TestFile ;
6+ use crate :: test_utils:: test_file:: { rename_file , TestFile } ;
97
108const AUTH_FAILED_MESSAGES : [ & str ; 6 ] = [
119 "workstation sudo: pam_unix(sudo:auth): authentication failure; logname=john uid=1000 euid=0 tty=/dev/pts/7 ruser=john rhost= user=john" ,
@@ -118,16 +116,6 @@ fn when_new_file_has_been_created_after_old_was_renamed_then_changes_in_new_file
118116 expect_update_callback_is_called_when_file_is_modified ( & mut file, & mut auth_file_watcher) ;
119117}
120118
121- fn rename_file ( filepath : & str , new_filename : & str ) {
122- println ! ( "Renaming test file {} to {}" , filepath, new_filename) ;
123- let new_path = Path :: new ( & filepath)
124- . parent ( )
125- . expect ( "Unable to get directory" )
126- . join ( new_filename) ;
127- let new_filepath = new_path. to_str ( ) . expect ( "Unable to build file path" ) ;
128- rename ( filepath, new_filepath) . expect ( "Unable to rename test file" ) ;
129- }
130-
131119#[ test]
132120fn when_monitored_file_has_been_truncated_then_changes_are_still_monitored ( ) {
133121 let mut file = TestFile :: new ( "auth-monitor-test" ) ;
Original file line number Diff line number Diff line change 11use std:: env:: temp_dir;
2- use std:: fs:: { remove_file, File } ;
2+ use std:: fs:: { remove_file, rename , File } ;
33use std:: io:: Write ;
4+ use std:: path:: Path ;
45
56use chrono:: Local ;
67
@@ -51,3 +52,13 @@ impl Drop for TestFile {
5152 self . remove ( ) ;
5253 }
5354}
55+
56+ pub fn rename_file ( filepath : & str , new_filename : & str ) {
57+ println ! ( "Renaming test file {} to {}" , filepath, new_filename) ;
58+ let new_path = Path :: new ( & filepath)
59+ . parent ( )
60+ . expect ( "Unable to get directory" )
61+ . join ( new_filename) ;
62+ let new_filepath = new_path. to_str ( ) . expect ( "Unable to build file path" ) ;
63+ rename ( filepath, new_filepath) . expect ( "Unable to rename test file" ) ;
64+ }
You can’t perform that action at this time.
0 commit comments