@@ -331,6 +331,8 @@ mod tests {
331
331
use std:: time:: Duration ;
332
332
333
333
use crossbeam_channel:: unbounded;
334
+ use serial_test:: serial;
335
+ use tempfile:: TempDir ;
334
336
335
337
use crate :: sync:: tests:: { debug_cmd_print, repo_init} ;
336
338
use crate :: sync:: RepoPath ;
@@ -368,4 +370,37 @@ mod tests {
368
370
369
371
assert ! ( result. is_ok( ) ) ;
370
372
}
373
+
374
+ #[ test]
375
+ #[ serial]
376
+ fn test_env_variables ( ) {
377
+ let ( _td, repo) = repo_init ( ) . unwrap ( ) ;
378
+ let git_dir = repo. path ( ) ;
379
+
380
+ let ( tx_git, _rx_git) = unbounded ( ) ;
381
+
382
+ let empty_dir = TempDir :: new ( ) . unwrap ( ) ;
383
+ let empty_path: RepoPath =
384
+ empty_dir. path ( ) . to_str ( ) . unwrap ( ) . into ( ) ;
385
+
386
+ let arc_current = Arc :: new ( Mutex :: new ( AsyncLogResult {
387
+ commits : Vec :: new ( ) ,
388
+ duration : Duration :: default ( ) ,
389
+ } ) ) ;
390
+ let arc_background = Arc :: new ( AtomicBool :: new ( false ) ) ;
391
+
392
+ std:: env:: set_var ( "GIT_DIR" , git_dir) ;
393
+
394
+ let result = AsyncLog :: fetch_helper_without_filter (
395
+ // We pass an empty path, thus testing whether `GIT_DIR`, set above, is taken into account.
396
+ & empty_path,
397
+ & arc_current,
398
+ & arc_background,
399
+ & tx_git,
400
+ ) ;
401
+
402
+ std:: env:: remove_var ( "GIT_DIR" ) ;
403
+
404
+ assert ! ( result. is_ok( ) ) ;
405
+ }
371
406
}
0 commit comments