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> {
282
282
#[ cfg( test) ]
283
283
mod tests {
284
284
use super :: * ;
285
- use crate :: sync:: tests:: repo_init;
285
+ use crate :: sync:: { commit , stage_add_file , tests:: repo_init} ;
286
286
use std:: { fs:: File , io:: Write , path:: Path } ;
287
287
288
288
#[ test]
289
289
fn test_discard_status ( ) {
290
- let file_path = Path :: new ( "foo " ) ;
290
+ let file_path = Path :: new ( "README.md " ) ;
291
291
let ( _td, repo) = repo_init ( ) . unwrap ( ) ;
292
292
let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
293
293
let repo_path: & RepoPath =
294
294
& root. as_os_str ( ) . to_str ( ) . unwrap ( ) . into ( ) ;
295
295
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 ( ) ;
300
303
301
304
let statuses =
302
305
get_status ( repo_path, StatusType :: WorkingDir , None )
You can’t perform that action at this time.
0 commit comments