History

more descriptive test names (#331)

Sebastian Thiel committed 4 years ago

Commit 049b2431 parent ae4f1221 file · +9 −9Browse files

Unified · Split

git-config/src/values.rs+9−9
@@ -382,13 +382,13 @@ pub mod path { · 381 unmodified lines
382 }382 }
383 383
384 #[cfg(test)]384 #[cfg(test)]
385 mod tests {385 mod interpolate_tests {
386 use std::borrow::Cow;386 use std::borrow::Cow;
387 387
388 use crate::values::{path::interpolate::Error, Path};388 use crate::values::{path::interpolate::Error, Path};
389 389
390 #[test]390 #[test]
391 fn not_interpolated() {391 fn no_interpolation_for_paths_without_tilde_or_prefix() {
392 let path = &b"/foo/bar"[..];392 let path = &b"/foo/bar"[..];
393 let actual = Path::from(Cow::Borrowed(path));393 let actual = Path::from(Cow::Borrowed(path));
394 assert_eq!(&*actual, path);394 assert_eq!(&*actual, path);
@@ -399,7 +399,7 @@ pub mod path { · 4 unmodified lines
399 }399 }
400 400
401 #[test]401 #[test]
402 fn empty_is_error() {402 fn empty_path_is_error() {
403 assert!(matches!(403 assert!(matches!(
404 Path::from(Cow::Borrowed("".as_bytes())).interpolate(None),404 Path::from(Cow::Borrowed("".as_bytes())).interpolate(None),
405 Err(Error::Missing { what: "path" })405 Err(Error::Missing { what: "path" })
@@ -407,7 +407,7 @@ pub mod path { · 1 unmodified line
407 }407 }
408 408
409 #[test]409 #[test]
410 fn prefix_interpolated() {410 fn prefix_substitutes_git_install_dir() {
411 for git_install_dir in &["/tmp/git", "C:\\git"] {411 for git_install_dir in &["/tmp/git", "C:\\git"] {
412 for (val, expected) in &[412 for (val, expected) in &[
413 (&b"%(prefix)/foo/bar"[..], "foo/bar"),413 (&b"%(prefix)/foo/bar"[..], "foo/bar"),
@@ -431,7 +431,7 @@ pub mod path { · 17 unmodified lines
431 }431 }
432 432
433 #[test]433 #[test]
434 fn disabled_prefix_interpolation() {434 fn prefix_substitution_skipped_with_dot_slash() {
435 let path = "./%(prefix)/foo/bar";435 let path = "./%(prefix)/foo/bar";
436 let git_install_dir = "/tmp/git";436 let git_install_dir = "/tmp/git";
437 assert_eq!(437 assert_eq!(
@@ -443,7 +443,7 @@ pub mod path { · 5 unmodified lines
443 }443 }
444 444
445 #[test]445 #[test]
446 fn tilde_interpolated() {446 fn tilde_substitutes_current_user() {
447 let path = &b"~/foo/bar"[..];447 let path = &b"~/foo/bar"[..];
448 let expected = format!(448 let expected = format!(
449 "{}{}foo/bar",449 "{}{}foo/bar",
@@ -459,16 +459,16 @@ pub mod path { · 9 unmodified lines
459 459
460 #[cfg(target_os = "windows")]460 #[cfg(target_os = "windows")]
461 #[test]461 #[test]
462 fn user_interpolated() {462 fn tilde_with_given_user_is_unsupported_on_windows() {
463 assert!(matches!(463 assert!(matches!(
464 Path::from(Cow::Borrowed(&b"~baz/foo/bar"[..])).interpolate(None),464 Path::from(Cow::Borrowed(&b"~baz/foo/bar"[..])).interpolate(None),
465 Err(path::interpolate::Error::UserInterpolationUnsupported)465 Err(Error::UserInterpolationUnsupported)
466 ));466 ));
467 }467 }
468 468
469 #[cfg(not(target_os = "windows"))]469 #[cfg(not(target_os = "windows"))]
470 #[test]470 #[test]
471 fn user_interpolated() {471 fn tilde_with_given_user() {
472 let user = std::env::var("USER").unwrap();472 let user = std::env::var("USER").unwrap();
473 let home = std::env::var("HOME").unwrap();473 let home = std::env::var("HOME").unwrap();
474 let specific_user_home = format!("~{}", user);474 let specific_user_home = format!("~{}", user);