Skip to content

Commit f8285fd

Browse files
committed
add unit tests to author #700
1 parent db2a2f6 commit f8285fd

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

src/info/author.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,44 @@ impl Serialize for Author {
5959
state.end()
6060
}
6161
}
62+
63+
#[cfg(test)]
64+
mod test {
65+
use super::*;
66+
67+
#[test]
68+
fn test_display_author() {
69+
let author = Author::new(
70+
"John Doe".into(),
71+
Some("[email protected]".into()),
72+
1500,
73+
2000,
74+
);
75+
76+
assert_eq!(
77+
format!("{}", author),
78+
"75% John Doe <[email protected]> 1500"
79+
);
80+
}
81+
82+
#[test]
83+
fn test_display_author_with_no_email() {
84+
let author = Author::new("John Doe".into(), None, 1500, 2000);
85+
86+
assert_eq!(format!("{}", author), "75% John Doe 1500");
87+
}
88+
89+
#[test]
90+
fn test_clear_email() {
91+
let mut author = Author::new(
92+
"John Doe".into(),
93+
Some("[email protected]".into()),
94+
1500,
95+
2000,
96+
);
97+
98+
author.clear_email();
99+
100+
assert!(author.email.is_none());
101+
}
102+
}

src/info/head_refs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ mod test {
4848
use super::*;
4949

5050
#[test]
51-
fn test_head_refs() {
51+
fn test_display_head_refs() {
5252
let head = HeadRefs::new("be561d5".into(), vec!["main".into(), "origin/main".into()]);
5353
assert_eq!(format!("{}", head), "be561d5 (main, origin/main)")
5454
}
5555

5656
#[test]
57-
fn test_head_refs_with_no_refs() {
57+
fn test_display_head_refs_with_no_refs() {
5858
let head = HeadRefs::new("be561d5".into(), vec![]);
5959
assert_eq!(format!("{}", head), "be561d5")
6060
}

0 commit comments

Comments
 (0)