Update tests for serde::duration

This commit is contained in:
Jonas Platte 2020-04-15 23:19:00 +02:00
parent c35d38c95f
commit 214d6521ef
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
2 changed files with 16 additions and 6 deletions

View File

@ -52,7 +52,7 @@ mod tests {
}
#[test]
fn test_deserialize_some_duration_as_milliseconds() {
fn test_deserialize_some() {
let json = json!({ "timeout": 3000 });
assert_eq!(
@ -64,7 +64,7 @@ mod tests {
}
#[test]
fn test_deserialize_empty_duration_as_milliseconds() {
fn test_deserialize_none_by_absence() {
let json = json!({});
assert_eq!(
@ -74,7 +74,17 @@ mod tests {
}
#[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 {
timeout: Some(Duration::new(2, 0)),
};
@ -85,7 +95,7 @@ mod tests {
}
#[test]
fn test_serialize_empty_duration_as_milliseconds() {
fn test_serialize_none() {
let request = DurationTest { timeout: None };
assert_eq!(serde_json::to_value(&request).unwrap(), json!({}));
}

View File

@ -48,7 +48,7 @@ mod tests {
}
#[test]
fn test_deserialize_duration_as_seconds() {
fn test_deserialize() {
let json = json!({ "timeout": 3 });
assert_eq!(
@ -60,7 +60,7 @@ mod tests {
}
#[test]
fn test_serialize_duration_as_seconds() {
fn test_serialize() {
let test = DurationTest {
timeout: Duration::from_millis(7000),
};