File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -280,3 +280,50 @@ pub fn get_status(
280280
281281 Ok ( res)
282282}
283+
284+ #[ cfg( test) ]
285+ mod tests {
286+ use std:: { fs:: File , io:: Write , path:: Path } ;
287+
288+ use tempfile:: TempDir ;
289+
290+ use crate :: {
291+ sync:: {
292+ status:: { get_status, StatusType } ,
293+ tests:: repo_init_bare,
294+ RepoPath ,
295+ } ,
296+ StatusItem , StatusItemType ,
297+ } ;
298+
299+ #[ test]
300+ #[ should_panic]
301+ fn test_get_status_with_workdir ( ) {
302+ let ( git_dir, _repo) = repo_init_bare ( ) . unwrap ( ) ;
303+
304+ let separate_workdir = TempDir :: new ( ) . unwrap ( ) ;
305+
306+ let file_path = Path :: new ( "foo" ) ;
307+ File :: create ( separate_workdir. path ( ) . join ( file_path) )
308+ . unwrap ( )
309+ . write_all ( b"a" )
310+ . unwrap ( ) ;
311+
312+ let repo_path = RepoPath :: Workdir {
313+ gitdir : git_dir. path ( ) . into ( ) ,
314+ workdir : separate_workdir. path ( ) . into ( ) ,
315+ } ;
316+
317+ let status =
318+ get_status ( & repo_path, StatusType :: WorkingDir , None )
319+ . unwrap ( ) ;
320+
321+ assert_eq ! (
322+ status,
323+ vec![ StatusItem {
324+ path: "foo" . into( ) ,
325+ status: StatusItemType :: New
326+ } ]
327+ ) ;
328+ }
329+ }
You can’t perform that action at this time.
0 commit comments