summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormario <mario-krehl@gmx.de>2016-07-04 15:38:03 +0200
committermario <mario-krehl@gmx.de>2016-07-04 15:38:03 +0200
commita363ce60df7efc1302109a8d3dd3fffe2fa84cc5 (patch)
treee3a742c0329ca097a78f3b93409e51d3514f8ac1 /src
parent7f11757d514bbc322a8671df9dcebe45a3861e74 (diff)
expanded the test for a single task from a string. import_tasks uses the tested function import_task, so we should only need to check if the Vector has the correct length and the items are ok.
Diffstat (limited to 'src')
-rw-r--r--src/import.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/import.rs b/src/import.rs
index 255effc..c921830 100644
--- a/src/import.rs
+++ b/src/import.rs
@@ -129,6 +129,14 @@ fn test_two() {
#[test]
fn test_one_single() {
use status::TaskStatus;
+ use date::Date;
+ use date::TASKWARRIOR_DATETIME_TEMPLATE;
+ use uuid::Uuid;
+ use chrono::naive::datetime::NaiveDateTime;
+ fn mkdate(s: &str) -> Date {
+ let n = NaiveDateTime::parse_from_str(s, TASKWARRIOR_DATETIME_TEMPLATE);
+ Date::from(n.unwrap())
+ }
let s = r#"
{
"id": 1,
@@ -145,8 +153,26 @@ fn test_one_single() {
"#;
let imported = import_task(&s);
assert!(imported.is_ok());
- let imported = imported.unwrap();
- assert!(imported.status() == &TaskStatus::Waiting);
+
+ // Check for every information
+ let task = imported.unwrap();
+ assert!(task.status() == &TaskStatus::Waiting);
+ assert!(task.description() == "some description");
+ assert!(task.entry().clone() == mkdate("20150619T165438Z"));
+ assert!(task.uuid().clone() == Uuid::parse_str("8ca953d5-18b4-4eb9-bd56-18f2e5b752f0").unwrap());
+ assert!(task.modified() == Some(&mkdate("20160327T164007Z")));
+ assert!(task.project() == Some(&String::from("someproject")));
+ if let Some(tags) = task.tags() {
+ for tag in tags {
+ let any_tag = [ "some", "tags", "are", "here", ]
+ .into_iter().any(|t| tag == *t);
+ assert!(any_tag, "Tag {} missing", tag);
+ }
+ } else {
+ assert!(false, "Tags completely missing");
+ }
+
+ assert!(task.wait() == Some(&mkdate("20160508T164007Z")));
}
#[test]