diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-02-12 15:23:24 +0100 |
---|---|---|
committer | Malte Brandy <malte.brandy@maralorn.de> | 2018-04-20 01:46:05 +0200 |
commit | 62d88aa939f159134e73edec2d52c52ce275e219 (patch) | |
tree | 55ef3d3ef651d1493ec6bbb038757846d018382a /src/task.rs | |
parent | 6d783dccf2ae5fd357d8b49ca9fd83b7c1a2a9dc (diff) |
Add builder type
Diffstat (limited to 'src/task.rs')
-rw-r--r-- | src/task.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/task.rs b/src/task.rs index b4b9387..8c9c47f 100644 --- a/src/task.rs +++ b/src/task.rs @@ -37,7 +37,8 @@ use uda::{UDA, UDAName, UDAValue}; /// /// It is deserializeable and serializeable via serde_json, so importing and exporting taskwarrior /// tasks is simply serializing and deserializing objects of this type. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Builder)] +#[builder(setter_prefix = "with")] pub struct Task { id: Option<u64>, @@ -856,4 +857,19 @@ mod test { assert!(back.contains("1234")); } + #[test] + fn test_builder_simple() { + use task::builder::TaskBuilder; + + let t = TaskBuilder::default() + .with_status(TaskStatus::Pending) + .with_description("test".into_string()) + .with_entry(mkdate("20150619T165438Z")) + .build(); + + assert_eq!(t.status(), TaskStatus::Pending); + assert_eq!(t.description(), "test".into_string()); + assert_eq!(t.entry(), mkdate("20150619T165438Z")); + } + } |