From ae0d8ed71f315d49bf10cc6b63344f399b56894d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 21 Apr 2016 16:30:43 -0400 Subject: 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. --- src/tests.rs | 18 ++++++++++++++++++ testdata/aliases | 1 + 2 files changed, 19 insertions(+) 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 ".to_owned(), + "alias farnsworth-hubert-2 Hubert Farnsworth ".to_owned() + ]), + find_alias_in_file( + &Alias { + alias: "farnsworth-hubert".to_owned(), + name: "Hubert Farnsworth".to_owned(), + email: "".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 +alias farnsworth-hubert-2 Hubert Farnsworth -- cgit v1.2.3