aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests.rs
diff options
context:
space:
mode:
authorTeddy Wing2016-04-21 20:58:21 -0400
committerTeddy Wing2016-04-21 20:59:38 -0400
commite008a5b8340ebf2a9965f3ce953a954997e0bb54 (patch)
treec0594a7254fadc41bf062f640ef9c475c1b39512 /src/tests.rs
parent3a5b7dd83642f5ab93aa70b612dcdbbc10e70935 (diff)
downloadmutt-alias-auto-add-e008a5b8340ebf2a9965f3ce953a954997e0bb54.tar.bz2
Add Alias#update_alias_id
This function takes a list of aliases and updates the current `Alias`'s alias using an auto-incremented numeric id. Not happy with the repetition in the tests. Need to figure out if there's a way to abstract that.
Diffstat (limited to 'src/tests.rs')
-rw-r--r--src/tests.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tests.rs b/src/tests.rs
index 0dc3901..f877408 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -88,3 +88,35 @@ fn find_alias_in_file_finds_a_match() {
)
);
}
+
+
+#[test]
+fn update_alias_id_does_nothing_given_an_empty_vector() {
+ let alias_identifier = "hooves-derpy";
+ let mut alias = Alias {
+ alias: alias_identifier.to_owned(),
+ name: "Derpy Hooves".to_owned(),
+ email: "derpyhooves@postmaster.pv".to_owned()
+ };
+ alias.update_alias_id(vec![]);
+
+ assert_eq!(alias_identifier, &alias.alias);
+}
+
+#[test]
+fn update_alias_id_increments_alias() {
+ let alias_identifier = "hooves-derpy";
+ let mut alias = Alias {
+ alias: alias_identifier.to_owned(),
+ name: "Derpy Hooves".to_owned(),
+ email: "derpyhooves@postmaster.pv".to_owned()
+ };
+ alias.update_alias_id(vec![
+ "hooves-derpy".to_owned(),
+ "hooves-derpy-2".to_owned(),
+ "hooves-derpy-3".to_owned(),
+ "hooves-derpy-4".to_owned()
+ ]);
+
+ assert_eq!("hooves-derpy-5", &alias.alias);
+}