mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-25 10:02:48 +03:00
Improve test for env variables (#2409)
* Add test for AsyncLog respecting GIT_DIR * Mark test as serial * Mark additional test as serial * Unwrap result to get more info in error case --------- Co-authored-by: extrawurst <776816+extrawurst@users.noreply.github.com>
This commit is contained in:
parent
1943988f7e
commit
9c4bd29fc8
@ -331,6 +331,8 @@ mod tests {
|
||||
use std::time::Duration;
|
||||
|
||||
use crossbeam_channel::unbounded;
|
||||
use serial_test::serial;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::sync::tests::{debug_cmd_print, repo_init};
|
||||
use crate::sync::RepoPath;
|
||||
@ -339,6 +341,7 @@ mod tests {
|
||||
use super::AsyncLogResult;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_smoke_in_subdir() {
|
||||
let (_td, repo) = repo_init().unwrap();
|
||||
let root = repo.path().parent().unwrap();
|
||||
@ -366,6 +369,39 @@ mod tests {
|
||||
&tx_git,
|
||||
);
|
||||
|
||||
assert!(result.is_ok());
|
||||
assert_eq!(result.unwrap(), ());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_env_variables() {
|
||||
let (_td, repo) = repo_init().unwrap();
|
||||
let git_dir = repo.path();
|
||||
|
||||
let (tx_git, _rx_git) = unbounded();
|
||||
|
||||
let empty_dir = TempDir::new().unwrap();
|
||||
let empty_path: RepoPath =
|
||||
empty_dir.path().to_str().unwrap().into();
|
||||
|
||||
let arc_current = Arc::new(Mutex::new(AsyncLogResult {
|
||||
commits: Vec::new(),
|
||||
duration: Duration::default(),
|
||||
}));
|
||||
let arc_background = Arc::new(AtomicBool::new(false));
|
||||
|
||||
std::env::set_var("GIT_DIR", git_dir);
|
||||
|
||||
let result = AsyncLog::fetch_helper_without_filter(
|
||||
// We pass an empty path, thus testing whether `GIT_DIR`, set above, is taken into account.
|
||||
&empty_path,
|
||||
&arc_current,
|
||||
&arc_background,
|
||||
&tx_git,
|
||||
);
|
||||
|
||||
std::env::remove_var("GIT_DIR");
|
||||
|
||||
assert_eq!(result.unwrap(), ());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user