Skip to content

Commit

Permalink
Adding test coverage to src/info/info_field.rs (#810)
Browse files Browse the repository at this point in the history
* Adding test coverage to src/info/info_field.rs

As requested as an item on task #700

* Implementing the suggested changes by reviewer
  • Loading branch information
alessandroasm authored Oct 7, 2022
1 parent 5e35023 commit 3cb479a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/info/info_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,40 @@ pub enum InfoType {
Size,
License,
}

#[cfg(test)]
mod test {
use super::*;

struct InfoFieldImpl(&'static str);

impl InfoField for InfoFieldImpl {
const TYPE: InfoType = InfoType::Project;

fn value(&self) -> String {
self.0.into()
}

fn title(&self) -> String {
String::from("title")
}
}

#[test]
fn test_info_field_get() {
let info = InfoFieldImpl("test");
assert_eq!(info.get(&[]), Some(String::from("test")));
}

#[test]
fn test_info_field_get_none_when_type_disabled() {
let info = InfoFieldImpl("test");
assert_eq!(info.get(&[InfoType::Project]), None);
}

#[test]
fn test_info_field_get_none_when_value_is_empty() {
let info = InfoFieldImpl("");
assert_eq!(info.get(&[]), None);
}
}

0 comments on commit 3cb479a

Please sign in to comment.