aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-04-21 16:30:43 -0400
committerTeddy Wing2016-04-21 16:30:43 -0400
commitae0d8ed71f315d49bf10cc6b63344f399b56894d (patch)
tree0b43ff64dacb5eed4dcd0d0402da215e48f3342a
parentf2ac8f66358bac4bcc6f3588bb55ffba9d9fecac (diff)
downloadmutt-alias-auto-add-ae0d8ed71f315d49bf10cc6b63344f399b56894d.tar.bz2
Add test for `find_alias_in_file` Ok case
New test for when alias matches are found in the given file. We want to match all aliases that don't have the searched email and start with the searched alias string. This gives us a list of aliases. We'll then be able to use this list to determine the highest-ranking id of the searched alias and append ${id}+1 to it to create our new alias.
-rw-r--r--src/tests.rs18
-rw-r--r--testdata/aliases1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/tests.rs b/src/tests.rs
index 0a512a1..df61825 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -70,3 +70,21 @@ fn find_alias_in_file_alias_is_new() {
)
);
}
+
+#[test]
+fn find_alias_in_file_finds_a_match() {
+ assert_eq!(
+ Ok(vec![
+ "alias farnsworth-hubert Hubert Farnsworth <professor@planetexpress.com>".to_owned(),
+ "alias farnsworth-hubert-2 Hubert Farnsworth <davincifan@planetexpress.com>".to_owned()
+ ]),
+ find_alias_in_file(
+ &Alias {
+ alias: "farnsworth-hubert".to_owned(),
+ name: "Hubert Farnsworth".to_owned(),
+ email: "<goodnewseveryone@planetexpress.com>".to_owned()
+ },
+ "./testdata/aliases"
+ )
+ );
+}
diff --git a/testdata/aliases b/testdata/aliases
index a8a08a8..d9c167a 100644
--- a/testdata/aliases
+++ b/testdata/aliases
@@ -1 +1,2 @@
alias farnsworth-hubert Hubert Farnsworth <professor@planetexpress.com>
+alias farnsworth-hubert-2 Hubert Farnsworth <davincifan@planetexpress.com>