summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDheepak Krishnamurthy <me@kdheepak.com>2021-02-13 18:28:22 -0700
committerGitHub <noreply@github.com>2021-02-13 18:28:22 -0700
commite40c961c074cdeec067854b617c30e69fa2c0448 (patch)
treec1f489a4158112fef1b13589959c8d80367b6764
parentbda6f4ef71140916fe163b19d78c78c616819ea1 (diff)
parent51036915f661133c0f92a8cb1622ce45eb3e7b69 (diff)
Merge pull request #88 from matthiasbeyer/kd/make-priority-string-type
-rw-r--r--examples/import_task.rs2
-rw-r--r--src/import.rs2
-rw-r--r--src/priority.rs19
-rw-r--r--src/task.rs43
4 files changed, 47 insertions, 19 deletions
diff --git a/examples/import_task.rs b/examples/import_task.rs
index d1a481b..ca6ba04 100644
--- a/examples/import_task.rs
+++ b/examples/import_task.rs
@@ -15,7 +15,7 @@ fn main() {
assert_eq!(*t.status(), TaskStatus::Pending);
assert_eq!(*t.description(), "Test task".to_owned());
assert_eq!(t.priority(), None);
+ assert_eq!(t.uda().get("priority"), None);
println!("Successfully imported:\n{:?}", t);
}
-
diff --git a/src/import.rs b/src/import.rs
index 68009b1..3d6c4e9 100644
--- a/src/import.rs
+++ b/src/import.rs
@@ -165,7 +165,7 @@ fn test_one_single() {
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(
+ let any_tag = ["some", "tags", "are", "here"].iter().any(
|t| tag == *t,
);
assert!(any_tag, "Tag {} missing", tag);
diff --git a/src/priority.rs b/src/priority.rs
index b0d33a4..6a04763 100644
--- a/src/priority.rs
+++ b/src/priority.rs
@@ -4,20 +4,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
-//! Module containing TaskPriority types and trait impls
+//! Module containing `TaskPriority` type
-/// Enum for the priorities taskwarrior supports.
-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
-pub enum TaskPriority {
- /// Low prio for a Task
- #[serde(rename = "L")]
- Low,
-
- /// Medium prio for a Task
- #[serde(rename = "M")]
- Medium,
-
- /// High prio for a Task
- #[serde(rename = "H")]
- High,
-}
+/// type definition for TaskPriority
+pub type TaskPriority = String;
diff --git a/src/task.rs b/src/task.rs
index 89d35d9..fd7e708 100644
--- a/src/task.rs
+++ b/src/task.rs
@@ -932,7 +932,7 @@ mod test {
if let Some(tags) = task.tags() {
for tag in tags {
- let any_tag = ["some", "tags", "are", "here"].into_iter().any(
+ let any_tag = ["some", "tags", "are", "here"].iter().any(
|t| tag == *t,
);
assert!(any_tag, "Tag {} missing", tag);
@@ -1072,6 +1072,47 @@ mod test {
assert!(back.contains("test_int_uda"));
assert!(back.contains("1234"));
}
+ #[test]
+ fn test_priority() {
+ let s = r#"{
+"id":9,
+"description":"Some long description for a task",
+"entry":"20201021T065503Z",
+"estimate":"30",
+"modified":"20210213T233603Z",
+"priority":"U",
+"status":"pending",
+"uuid":"6c4c9ee8-d6c4-4d64-a84d-bf9cb710684e",
+"urgency":23
+}"#;
+
+ println!("{}", s);
+
+ let task = serde_json::from_str(s);
+ println!("{:?}", task);
+ assert!(task.is_ok());
+ let task: Task = task.unwrap();
+
+ if let Some(priority) = task.priority() {
+ assert!(priority == &"U".to_string());
+ } else {
+ assert!(false, "Priority completely missing");
+ }
+
+ let back = serde_json::to_string_pretty(&task);
+ assert!(back.is_ok());
+ let back = back.unwrap();
+ println!("{}", back);
+ assert!(back.contains("description"));
+ assert!(back.contains("Some long description for a task"));
+ assert!(back.contains("entry"));
+ assert!(back.contains("20201021T065503Z"));
+ assert!(back.contains("priority"));
+ assert!(back.contains("status"));
+ assert!(back.contains("pending"));
+ assert!(back.contains("uuid"));
+ assert!(back.contains("6c4c9ee8-d6c4-4d64-a84d-bf9cb710684e"));
+ }
#[test]
fn test_builder_simple() {