History

Make tests more robust; fix windows tests (#450)

Sebastian Thiel committed 4 years ago

Commit 1983fbc1 parent 8c686e03 files · +14 −8Browse files

Unified · Split

3 files
  1. git-repository/src/config/snapshot/credential_helpers.rs +9 −6
  2. git-repository/tests/fixtures/make_remote_repos.sh +2 −2
  3. tests/tools/src/lib.rs +3 −0
git-repository/src/config/snapshot/credential_helpers.rs+9−6
@@ -17,7 +17,7 @@ mod error { · 16 unmodified lines
17 },17 },
18 }18 }
19}19}
20use crate::bstr::ByteVec;20use crate::bstr::{ByteSlice, ByteVec};
21pub use error::Error;21pub use error::Error;
22 22
23impl Snapshot<'_> {23impl Snapshot<'_> {
@@ -45,14 +45,17 @@ impl Snapshot<'_> { · 21 unmodified lines
45 match section.header().subsection_name() {45 match section.header().subsection_name() {
46 Some(_) => {}46 Some(_) => {}
47 None => {47 None => {
48 for value in section.values("helper") {48 for value in section.values("helper").into_iter().filter(|v| !v.trim().is_empty()) {
49 programs.push(git_credentials::Program::from_custom_definition(value.into_owned()));49 programs.push(git_credentials::Program::from_custom_definition(value.into_owned()));
50 }50 }
51 if let Some(Some(user)) = (!url_had_user_initially).then(|| {51 if let Some(Some(user)) = (!url_had_user_initially).then(|| {
52 section.value("username").and_then(|n| {52 section
53 let n: Vec<_> = Cow::into_owned(n).into();53 .value("username")
54 n.into_string().ok()54 .filter(|n| !n.trim().is_empty())
55 })55 .and_then(|n| {
56 let n: Vec<_> = Cow::into_owned(n).into();
57 n.into_string().ok()
58 })
56 }) {59 }) {
57 url.set_user(Some(user));60 url.set_user(Some(user));
58 }61 }
git-repository/tests/fixtures/make_remote_repos.sh+2−2
@@ -199,8 +199,8 @@ git clone --shared base credential-helpers · 198 unmodified lines
199 } >> baseline.git199 } >> baseline.git
200 }200 }
201 201
202 git config credential.helper ''202 git config credential.helper ""
203 git config credential.helper global203 git config --add credential.helper global
204 git config credential.https://example.com:8080.helper example-with-port204 git config credential.https://example.com:8080.helper example-with-port
205 git config credential.https://example.com:8080/path.helper example-with-port-and-path205 git config credential.https://example.com:8080/path.helper example-with-port-and-path
206 git config credential.https://example.com:8080/path.usehttppath 1206 git config credential.https://example.com:8080/path.usehttppath 1
tests/tools/src/lib.rs+3−0
@@ -317,6 +317,9 @@ fn scripted_fixture_repo_read_only_with_args_inner( · 316 unmodified lines
317 .stderr(std::process::Stdio::piped())317 .stderr(std::process::Stdio::piped())
318 .current_dir(&script_result_directory)318 .current_dir(&script_result_directory)
319 .env_remove("GIT_DIR")319 .env_remove("GIT_DIR")
320 .env_remove("GIT_ASKPASS")
321 .env_remove("SSH_ASKPASS")
322 .env("GIT_TERMINAL_PROMPT", "false")
320 .env("GIT_AUTHOR_DATE", "2000-01-01 00:00:00 +0000")323 .env("GIT_AUTHOR_DATE", "2000-01-01 00:00:00 +0000")
321 .env("GIT_AUTHOR_EMAIL", "author@example.com")324 .env("GIT_AUTHOR_EMAIL", "author@example.com")
322 .env("GIT_AUTHOR_NAME", "author")325 .env("GIT_AUTHOR_NAME", "author")