Skip to content

Commit

Permalink
Add a few tests more, remove the duration milliseconds parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed May 24, 2024
1 parent c0d363e commit 03f6767
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions crates/ingress-http/src/handler/service_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,7 @@ fn parse_headers(headers: HeaderMap) -> Result<Vec<Header>, HandlerError> {
#[serde_as]
#[derive(Deserialize)]
#[serde(transparent)]
struct DurationQueryParam(
#[serde_as(
as = "serde_with::PickFirst<(restate_serde_util::DurationString, serde_with::DurationMilliSeconds<String>)>"
)]
Duration,
);
struct DurationQueryParam(#[serde_as(as = "restate_serde_util::DurationString")] Duration);

fn parse_delay(query: Option<&str>) -> Result<Option<Duration>, HandlerError> {
if query.is_none() {
Expand Down Expand Up @@ -385,8 +380,12 @@ mod tests {
Duration::from_secs(60),
);
assert_eq!(
parse_delay(Some("delay=60000")).unwrap().unwrap(),
Duration::from_secs(60),
)
parse_delay(Some("delay=60ms")).unwrap().unwrap(),
Duration::from_millis(60),
);
assert_eq!(
parse_delay(Some("delay=60000ms")).unwrap().unwrap(),
Duration::from_millis(60000),
);
}
}

0 comments on commit 03f6767

Please sign in to comment.