From 0b7111a0e5f7d96acbf2158041ba54a62f829294 Mon Sep 17 00:00:00 2001 From: o2sh Date: Tue, 16 Aug 2022 00:39:22 +0200 Subject: [PATCH] add unit tests to head_refs #700 --- src/info/head_refs.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/info/head_refs.rs b/src/info/head_refs.rs index e23869b73..59abc23b6 100644 --- a/src/info/head_refs.rs +++ b/src/info/head_refs.rs @@ -42,3 +42,20 @@ impl Serialize for HeadRefs { state.end() } } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_head_refs() { + let head = HeadRefs::new("be561d5".into(), vec!["main".into(), "origin/main".into()]); + assert_eq!(format!("{}", head), "be561d5 (main, origin/main)") + } + + #[test] + fn test_head_refs_with_no_refs() { + let head = HeadRefs::new("be561d5".into(), vec![]); + assert_eq!(format!("{}", head), "be561d5") + } +}