Skip to content

Commit

Permalink
Fix Uppercased Duration input for jig log
Browse files Browse the repository at this point in the history
  • Loading branch information
Baarsgaard committed Oct 8, 2023
1 parent 73595ed commit 16599e0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions jira/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl TryFrom<String> for WorklogDuration {
eyre::Error: From<std::fmt::Error>,
{
let worklog_re = WORKLOG_RE.get_or_init(|| {
Regex::new(r"([0-9]+(?:\.[0-9]+)?)[wdhm]?").expect("Unable to compile WORKLOG_RE")
Regex::new(r"([0-9]+(?:\.[0-9]+)?)[WwDdHhMm]?").expect("Unable to compile WORKLOG_RE")
});

match worklog_re.captures(&value) {
Expand All @@ -164,7 +164,7 @@ impl TryFrom<String> for WorklogDuration {

multiplier.unwrap_or(60) // Default to minutes
} else {
60 // Default to minutes
60 // Unit omitted default to minutes
};

let seconds = worklog
Expand Down Expand Up @@ -299,6 +299,7 @@ mod tests {
#[test]
fn worklog_try_from_all_inputs() {
let worklogs = vec![
(60, "1"),
(60, "1m"),
(3600, "1h"),
(3600 * 8, "1d"),
Expand All @@ -318,8 +319,8 @@ mod tests {
}
#[test]
fn uppercase_worklog_duration() {
let wl = WorklogDuration::try_from(String::from("1H")).unwrap().0;
assert_eq!(String::from("3600"), wl);
let wl = WorklogDuration::try_from(String::from("2H")).unwrap().0;
assert_eq!(String::from("7200"), wl);
}

#[test]
Expand Down

0 comments on commit 16599e0

Please sign in to comment.