From 406f63e02eec25ff191d4938f9842200ab7795d6 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sat, 19 Nov 2022 19:44:40 +0100 Subject: [PATCH] Update to work around deprecated chrono API --- Cargo.toml | 2 +- src/contact/create.rs | 2 +- src/contact/info.rs | 4 ++-- src/domain/create.rs | 4 ++-- src/domain/info.rs | 6 +++--- src/domain/renew.rs | 4 ++-- src/domain/transfer.rs | 12 ++++++------ src/hello.rs | 2 +- src/host/create.rs | 2 +- src/host/info.rs | 4 ++-- src/message/poll.rs | 34 ++++++++++++++++++++++++++-------- 11 files changed, 47 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b1586ce..f3eb42c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ default = ["tokio-rustls"] [dependencies] async-trait = "0.1.52" celes = "2.1" -chrono = { version = "0.4", features = ["serde"] } +chrono = { version = "0.4.23", features = ["serde"] } quick-xml = { version = "0.23", features = [ "serialize" ] } serde = { version = "1.0", features = ["derive"] } tokio = { version = "1.0", features = [ "full" ] } diff --git a/src/contact/create.rs b/src/contact/create.rs index a2fe594..315bdf9 100644 --- a/src/contact/create.rs +++ b/src/contact/create.rs @@ -138,7 +138,7 @@ mod tests { assert_eq!(results.create_data.id, "eppdev-contact-4".into()); assert_eq!( results.create_data.created_at, - Utc.ymd(2021, 7, 25).and_hms(16, 5, 32) + Utc.with_ymd_and_hms(2021, 7, 25, 16, 5, 32).unwrap(), ); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into()); diff --git a/src/contact/info.rs b/src/contact/info.rs index 6af38a8..3459e45 100644 --- a/src/contact/info.rs +++ b/src/contact/info.rs @@ -161,7 +161,7 @@ mod tests { assert_eq!(result.info_data.creator_id, "SYSTEM".into()); assert_eq!( result.info_data.created_at, - Utc.ymd(2021, 7, 23).and_hms(13, 9, 9) + Utc.with_ymd_and_hms(2021, 7, 23, 13, 9, 9).unwrap(), ); assert_eq!( *(result.info_data.updater_id.as_ref().unwrap()), @@ -169,7 +169,7 @@ mod tests { ); assert_eq!( result.info_data.updated_at, - Some(Utc.ymd(2021, 7, 23).and_hms(13, 9, 9)) + Utc.with_ymd_and_hms(2021, 7, 23, 13, 9, 9).single() ); assert_eq!((*auth_info).password, "eppdev-387323".into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into()); diff --git a/src/domain/create.rs b/src/domain/create.rs index 1ea9fe8..d11ee4f 100644 --- a/src/domain/create.rs +++ b/src/domain/create.rs @@ -226,11 +226,11 @@ mod tests { assert_eq!(result.create_data.name, "eppdev-2.com".into()); assert_eq!( result.create_data.created_at, - Utc.ymd(2021, 7, 25).and_hms(18, 11, 35) + Utc.with_ymd_and_hms(2021, 7, 25, 18, 11, 35).unwrap() ); assert_eq!( *result.create_data.expiring_at.as_ref().unwrap(), - Utc.ymd(2022, 7, 25).and_hms(18, 11, 34) + Utc.with_ymd_and_hms(2022, 7, 25, 18, 11, 34).unwrap() ); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into()); diff --git a/src/domain/info.rs b/src/domain/info.rs index e91ac48..464a32b 100644 --- a/src/domain/info.rs +++ b/src/domain/info.rs @@ -180,7 +180,7 @@ mod tests { ); assert_eq!( *result.info_data.created_at.as_ref().unwrap(), - Utc.ymd(2021, 7, 23).and_hms(15, 31, 20) + Utc.with_ymd_and_hms(2021, 7, 23, 15, 31, 20).unwrap() ); assert_eq!( *result.info_data.updater_id.as_ref().unwrap(), @@ -188,11 +188,11 @@ mod tests { ); assert_eq!( *result.info_data.updated_at.as_ref().unwrap(), - Utc.ymd(2021, 7, 23).and_hms(15, 31, 21) + Utc.with_ymd_and_hms(2021, 7, 23, 15, 31, 21).unwrap() ); assert_eq!( *result.info_data.expiring_at.as_ref().unwrap(), - Utc.ymd(2023, 7, 23).and_hms(15, 31, 20) + Utc.with_ymd_and_hms(2023, 7, 23, 15, 31, 20).unwrap() ); assert_eq!((*auth_info).password, "epP4uthd#v".into()); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into()); diff --git a/src/domain/renew.rs b/src/domain/renew.rs index 653e8b4..078dca6 100644 --- a/src/domain/renew.rs +++ b/src/domain/renew.rs @@ -85,7 +85,7 @@ mod tests { #[test] fn command() { - let exp_date = NaiveDate::from_ymd(2022, 7, 23); + let exp_date = NaiveDate::from_ymd_opt(2022, 7, 23).unwrap(); let object = DomainRenew::new("eppdev.com", exp_date, Period::years(1).unwrap()); assert_serialized("request/domain/renew.xml", &object); } @@ -101,7 +101,7 @@ mod tests { assert_eq!(result.renew_data.name, "eppdev-1.com".into()); assert_eq!( *result.renew_data.expiring_at.as_ref().unwrap(), - Utc.ymd(2024, 7, 23).and_hms(15, 31, 20) + Utc.with_ymd_and_hms(2024, 7, 23, 15, 31, 20).unwrap() ); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into()); diff --git a/src/domain/transfer.rs b/src/domain/transfer.rs index 865119e..6c5cf86 100644 --- a/src/domain/transfer.rs +++ b/src/domain/transfer.rs @@ -189,16 +189,16 @@ mod tests { assert_eq!(result.transfer_data.requester_id, "eppdev".into()); assert_eq!( result.transfer_data.requested_at, - Utc.ymd(2021, 7, 23).and_hms(15, 31, 21), + Utc.with_ymd_and_hms(2021, 7, 23, 15, 31, 21).unwrap(), ); assert_eq!(result.transfer_data.ack_id, "ClientY".into()); assert_eq!( result.transfer_data.ack_by, - Utc.ymd(2021, 7, 28).and_hms(15, 31, 21) + Utc.with_ymd_and_hms(2021, 7, 28, 15, 31, 21).unwrap() ); assert_eq!( result.transfer_data.expiring_at, - Some(Utc.ymd(2022, 7, 2).and_hms(14, 53, 19)), + Utc.with_ymd_and_hms(2022, 7, 2, 14, 53, 19).single(), ); assert_eq!(*object.tr_ids.client_tr_id.as_ref().unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into()); @@ -247,16 +247,16 @@ mod tests { assert_eq!(result.transfer_data.requester_id, "eppdev".into()); assert_eq!( result.transfer_data.requested_at, - Utc.ymd(2021, 7, 23).and_hms(15, 31, 21) + Utc.with_ymd_and_hms(2021, 7, 23, 15, 31, 21).unwrap() ); assert_eq!(result.transfer_data.ack_id, "ClientY".into()); assert_eq!( result.transfer_data.ack_by, - Utc.ymd(2021, 7, 28).and_hms(15, 31, 21) + Utc.with_ymd_and_hms(2021, 7, 28, 15, 31, 21).unwrap() ); assert_eq!( result.transfer_data.expiring_at, - Some(Utc.ymd(2022, 7, 2).and_hms(14, 53, 19)) + Utc.with_ymd_and_hms(2022, 7, 2, 14, 53, 19).single() ); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into()); diff --git a/src/hello.rs b/src/hello.rs index 6a69429..0f7fa70 100644 --- a/src/hello.rs +++ b/src/hello.rs @@ -323,7 +323,7 @@ mod tests { assert_eq!(object.data.service_id, "ISPAPI EPP Server"); assert_eq!( object.data.service_date, - Utc.ymd(2021, 7, 25).and_hms(14, 51, 17) + Utc.with_ymd_and_hms(2021, 7, 25, 14, 51, 17).unwrap() ); assert_eq!(object.data.svc_menu.options.version, "1.0".into()); assert_eq!(object.data.svc_menu.options.lang, "en".into()); diff --git a/src/host/create.rs b/src/host/create.rs index 7776000..461b050 100644 --- a/src/host/create.rs +++ b/src/host/create.rs @@ -101,7 +101,7 @@ mod tests { assert_eq!(result.create_data.name, "host2.eppdev-1.com".into()); assert_eq!( result.create_data.created_at, - Utc.ymd(2021, 7, 26).and_hms(5, 28, 55) + Utc.with_ymd_and_hms(2021, 7, 26, 5, 28, 55).unwrap() ); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into()); diff --git a/src/host/info.rs b/src/host/info.rs index 67de15a..da06d96 100644 --- a/src/host/info.rs +++ b/src/host/info.rs @@ -140,7 +140,7 @@ mod tests { assert_eq!(result.info_data.creator_id, "creator".into()); assert_eq!( result.info_data.created_at, - Utc.ymd(2021, 7, 26).and_hms(5, 28, 55) + Utc.with_ymd_and_hms(2021, 7, 26, 5, 28, 55).unwrap() ); assert_eq!( *(result.info_data.updater_id.as_ref().unwrap()), @@ -148,7 +148,7 @@ mod tests { ); assert_eq!( result.info_data.updated_at, - Some(Utc.ymd(2021, 7, 26).and_hms(5, 28, 55)) + Utc.with_ymd_and_hms(2021, 7, 26, 5, 28, 55).single() ); assert_eq!(object.tr_ids.client_tr_id.unwrap(), CLTRID.into()); assert_eq!(object.tr_ids.server_tr_id, SVTRID.into()); diff --git a/src/message/poll.rs b/src/message/poll.rs index b30c870..8747765 100644 --- a/src/message/poll.rs +++ b/src/message/poll.rs @@ -80,7 +80,10 @@ mod tests { ); assert_eq!(msg.count, 5); assert_eq!(msg.id, "12345".to_string()); - assert_eq!(msg.date, Some(Utc.ymd(2021, 7, 23).and_hms(19, 12, 43))); + assert_eq!( + msg.date, + Utc.with_ymd_and_hms(2021, 7, 23, 19, 12, 43).single() + ); assert_eq!( *(msg.message.as_ref().unwrap()), "Transfer requested.".into() @@ -90,12 +93,18 @@ mod tests { assert_eq!(tr.name, "eppdev-transfer.com".into()); assert_eq!(tr.transfer_status, "pending".into()); assert_eq!(tr.requester_id, "eppdev".into()); - assert_eq!(tr.requested_at, Utc.ymd(2021, 7, 23).and_hms(15, 31, 21)); + assert_eq!( + tr.requested_at, + Utc.with_ymd_and_hms(2021, 7, 23, 15, 31, 21).unwrap() + ); assert_eq!(tr.ack_id, "ClientY".into()); - assert_eq!(tr.ack_by, Utc.ymd(2021, 7, 28).and_hms(15, 31, 21)); + assert_eq!( + tr.ack_by, + Utc.with_ymd_and_hms(2021, 7, 28, 15, 31, 21).unwrap() + ); assert_eq!( tr.expiring_at, - Some(Utc.ymd(2022, 7, 2).and_hms(14, 53, 19)) + Utc.with_ymd_and_hms(2022, 7, 2, 14, 53, 19).single() ); } else { panic!("Wrong type"); @@ -121,7 +130,10 @@ mod tests { ); assert_eq!(msg.count, 4); assert_eq!(msg.id, "12345".to_string()); - assert_eq!(msg.date, Some(Utc.ymd(2022, 1, 2).and_hms(11, 30, 45))); + assert_eq!( + msg.date, + Utc.with_ymd_and_hms(2022, 1, 2, 11, 30, 45).single() + ); assert_eq!( *(msg.message.as_ref().unwrap()), "Unused objects policy".into() @@ -138,11 +150,14 @@ mod tests { .any(|a| a == &IpAddr::from([1, 1, 1, 1]))); assert_eq!(host.client_id, "1234".into()); assert_eq!(host.creator_id, "user".into()); - assert_eq!(host.created_at, Utc.ymd(2021, 12, 1).and_hms(22, 40, 48)); + assert_eq!( + host.created_at, + Utc.with_ymd_and_hms(2021, 12, 1, 22, 40, 48).unwrap() + ); assert_eq!(host.updater_id, Some("user".into())); assert_eq!( host.updated_at, - Some(Utc.ymd(2021, 12, 1).and_hms(22, 40, 48)) + Utc.with_ymd_and_hms(2021, 12, 1, 22, 40, 48).single() ); } else { panic!("Wrong type"); @@ -168,7 +183,10 @@ mod tests { assert_eq!(msg.count, 4); assert_eq!(msg.id, "12346".to_string()); - assert_eq!(msg.date, Some(Utc.ymd(2000, 6, 8).and_hms(22, 10, 0))); + assert_eq!( + msg.date, + Utc.with_ymd_and_hms(2000, 6, 8, 22, 10, 0).single() + ); assert_eq!( *(msg.message.as_ref().unwrap()), "Credit balance low.".into()