Update tests for serde::duration
This commit is contained in:
parent
c35d38c95f
commit
214d6521ef
@ -52,7 +52,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_some_duration_as_milliseconds() {
|
fn test_deserialize_some() {
|
||||||
let json = json!({ "timeout": 3000 });
|
let json = json!({ "timeout": 3000 });
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -64,7 +64,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_empty_duration_as_milliseconds() {
|
fn test_deserialize_none_by_absence() {
|
||||||
let json = json!({});
|
let json = json!({});
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -74,7 +74,17 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize_some_duration_as_milliseconds() {
|
fn test_deserialize_none_by_null() {
|
||||||
|
let json = json!({ "timeout": null });
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
serde_json::from_value::<DurationTest>(json).unwrap(),
|
||||||
|
DurationTest { timeout: None },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_serialize_some() {
|
||||||
let request = DurationTest {
|
let request = DurationTest {
|
||||||
timeout: Some(Duration::new(2, 0)),
|
timeout: Some(Duration::new(2, 0)),
|
||||||
};
|
};
|
||||||
@ -85,7 +95,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize_empty_duration_as_milliseconds() {
|
fn test_serialize_none() {
|
||||||
let request = DurationTest { timeout: None };
|
let request = DurationTest { timeout: None };
|
||||||
assert_eq!(serde_json::to_value(&request).unwrap(), json!({}));
|
assert_eq!(serde_json::to_value(&request).unwrap(), json!({}));
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_deserialize_duration_as_seconds() {
|
fn test_deserialize() {
|
||||||
let json = json!({ "timeout": 3 });
|
let json = json!({ "timeout": 3 });
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -60,7 +60,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_serialize_duration_as_seconds() {
|
fn test_serialize() {
|
||||||
let test = DurationTest {
|
let test = DurationTest {
|
||||||
timeout: Duration::from_millis(7000),
|
timeout: Duration::from_millis(7000),
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user