From e71b65aa0d6e9bb2187c6a4e9929ab7559c936cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kj=C3=A4ll?= Date: Wed, 23 Dec 2020 21:36:57 +0100 Subject: [PATCH 1/2] test for verifying that the Repository::config() function returns a config object that have the local repo as highest prio --- src/repo.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/repo.rs b/src/repo.rs index 17a54f34c5..a61cbbf695 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -3621,4 +3621,25 @@ mod tests { // reverting twice restores `foo` file assert!(foo_file.exists()); } + + #[test] + fn smoke_config_write_and_read() { + let td = TempDir::new().unwrap(); + let path = td.path(); + + let repo = Repository::init(path).unwrap(); + + let mut config = repo.config().unwrap(); + + config.set_bool("commit.gpgsign", false).unwrap(); + + let c = fs::read_to_string(path.join(".git").join("config")).unwrap(); + + assert!(c.contains("[commit]")); + assert!(c.contains("gpgsign = false")); + + let config = repo.config().unwrap(); + + assert!(!config.get_bool("commit.gpgsign").unwrap()); + } } From 8c24d4712e3ab96dbd7eb7b166e9d0b941688267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kj=C3=A4ll?= Date: Thu, 24 Dec 2020 11:39:31 +0100 Subject: [PATCH 2/2] used the test::repo_init() helper method instead --- src/repo.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/repo.rs b/src/repo.rs index a61cbbf695..7eb02ca62a 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -3624,16 +3624,13 @@ mod tests { #[test] fn smoke_config_write_and_read() { - let td = TempDir::new().unwrap(); - let path = td.path(); - - let repo = Repository::init(path).unwrap(); + let (td, repo) = crate::test::repo_init(); let mut config = repo.config().unwrap(); config.set_bool("commit.gpgsign", false).unwrap(); - let c = fs::read_to_string(path.join(".git").join("config")).unwrap(); + let c = fs::read_to_string(td.path().join(".git").join("config")).unwrap(); assert!(c.contains("[commit]")); assert!(c.contains("gpgsign = false"));