File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -215,3 +215,34 @@ pub fn discard_status(repo_path: &RepoPath) -> Result<bool> {
215215
216216 Ok ( true )
217217}
218+
219+ #[ cfg( test) ]
220+ mod tests {
221+ use super :: * ;
222+ use crate :: sync:: tests:: repo_init;
223+ use std:: { fs:: File , io:: Write , path:: Path } ;
224+
225+ #[ test]
226+ fn test_discard_status ( ) {
227+ let file_path = Path :: new ( "foo" ) ;
228+ let ( _td, repo) = repo_init ( ) . unwrap ( ) ;
229+ let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
230+ let repo_path: & RepoPath =
231+ & root. as_os_str ( ) . to_str ( ) . unwrap ( ) . into ( ) ;
232+
233+ File :: create ( root. join ( file_path) )
234+ . unwrap ( )
235+ . write_all ( b"test\n foo" )
236+ . unwrap ( ) ;
237+
238+ let statuses = get_status ( repo_path, StatusType :: WorkingDir , None )
239+ . unwrap ( ) ;
240+ assert_eq ! ( statuses. len( ) , 1 ) ;
241+
242+ discard_status ( repo_path) . unwrap ( ) ;
243+
244+ let statuses = get_status ( repo_path, StatusType :: WorkingDir , None )
245+ . unwrap ( ) ;
246+ assert_eq ! ( statuses. len( ) , 0 ) ;
247+ }
248+ }
You can’t perform that action at this time.
0 commit comments