File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -282,21 +282,24 @@ pub fn discard_status(repo_path: &RepoPath) -> Result<bool> {
282282#[ cfg( test) ]
283283mod tests {
284284 use super :: * ;
285- use crate :: sync:: tests:: repo_init;
285+ use crate :: sync:: { commit , stage_add_file , tests:: repo_init} ;
286286 use std:: { fs:: File , io:: Write , path:: Path } ;
287287
288288 #[ test]
289289 fn test_discard_status ( ) {
290- let file_path = Path :: new ( "foo " ) ;
290+ let file_path = Path :: new ( "README.md " ) ;
291291 let ( _td, repo) = repo_init ( ) . unwrap ( ) ;
292292 let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
293293 let repo_path: & RepoPath =
294294 & root. as_os_str ( ) . to_str ( ) . unwrap ( ) . into ( ) ;
295295
296- File :: create ( root. join ( file_path) )
297- . unwrap ( )
298- . write_all ( b"test\n foo" )
299- . unwrap ( ) ;
296+ let mut file = File :: create ( root. join ( file_path) ) . unwrap ( ) ;
297+
298+ // initial commit
299+ stage_add_file ( repo_path, file_path) . unwrap ( ) ;
300+ commit ( repo_path, "commit msg" ) . unwrap ( ) ;
301+
302+ writeln ! ( file, "Test for discard_status" ) . unwrap ( ) ;
300303
301304 let statuses =
302305 get_status ( repo_path, StatusType :: WorkingDir , None )
You can’t perform that action at this time.
0 commit comments