aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests.rs
diff options
context:
space:
mode:
authorTeddy Wing2016-04-24 09:31:25 -0400
committerTeddy Wing2016-04-24 09:31:25 -0400
commit2e844b5c528a39e75702d0b412b0396080fa103e (patch)
treeb3b97c61601bfef24f3f8bab5075e4b1362adf65 /src/tests.rs
parent7c9439bc11ae95b6f2da59eabf2950d15df4d558 (diff)
downloadmutt-alias-auto-add-2e844b5c528a39e75702d0b412b0396080fa103e.tar.bz2
Write alias even if we haven't found a matching one
If we get an `AliasSearchError::NotFound` error we still want to write the alias to the file. After all, it's an email we haven't encountered yet so we should store an alias for it. If the email exists, we can do what we were doing before and change the current alias to be unique. Rename our "append" `write_to_file` test method to be a little more clear about its purpose. Create a new `write_to_file` test function that tests the case we're adding here. Note that having these two tests together seems to cause a race condition because they're both using the same temporary test file. If we run tests with `RUST_TEST_THREADS=1 cargo test` then they pass. Will see about fixing that next.
Diffstat (limited to 'src/tests.rs')
-rw-r--r--src/tests.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/tests.rs b/src/tests.rs
index c897a32..f00d103 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -144,7 +144,7 @@ fn alias_write_to_file_helper<F>(alias: &mut Alias, f: F) -> String
}
#[test]
-fn alias_write_to_file_must_write_given_alias_to_file() {
+fn alias_write_to_file_must_write_unique_alias_to_file_if_one_already_exists() {
let mut alias = update_alias_id_sample_alias();
let alias_line = alias_write_to_file_helper(&mut alias, |alias: &Alias, filename: &str| {
// Write a duplicate alias so that `write_to_file` is able to append a
@@ -158,3 +158,14 @@ fn alias_write_to_file_must_write_given_alias_to_file() {
assert_eq!(alias.to_string(), alias_line);
}
+
+#[test]
+#[allow(unused_variables)]
+fn alias_write_to_file_must_write_given_alias_to_file() {
+ let mut alias = update_alias_id_sample_alias();
+ let alias_line = alias_write_to_file_helper(
+ &mut alias,
+ |alias: &Alias, filename: &str| {});
+
+ assert_eq!(alias.to_string(), alias_line);
+}