From 69eb4b8ea8c6d7499b6fb7c9907d7f2a720f21ba Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Fri, 16 Dec 2022 18:14:25 +0800 Subject: [PATCH] Refactor the use of deprecated chrono methods (#1312) --- tests/parallel_tests.rs | 8 ++++---- tests/self_join_tests.rs | 6 +++--- tests/uuid_tests.rs | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/parallel_tests.rs b/tests/parallel_tests.rs index 8eb18dbd..73dae78e 100644 --- a/tests/parallel_tests.rs +++ b/tests/parallel_tests.rs @@ -27,8 +27,8 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> { key: "markup".to_owned(), value: "1.18".to_owned(), bytes: vec![1, 2, 3], - date: Some(Date::from_ymd(2021, 9, 27)), - time: Some(Time::from_hms(11, 32, 55)), + date: Some(Date::from_ymd_opt(2021, 9, 27).unwrap()), + time: Some(Time::from_hms_opt(11, 32, 55).unwrap()), }, metadata::Model { uuid: Uuid::new_v4(), @@ -36,8 +36,8 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> { key: "exchange_rate".to_owned(), value: "0.78".to_owned(), bytes: vec![1, 2, 3], - date: Some(Date::from_ymd(2021, 9, 27)), - time: Some(Time::from_hms(11, 32, 55)), + date: Some(Date::from_ymd_opt(2021, 9, 27).unwrap()), + time: Some(Time::from_hms_opt(11, 32, 55).unwrap()), }, metadata::Model { uuid: Uuid::new_v4(), diff --git a/tests/self_join_tests.rs b/tests/self_join_tests.rs index 0c85a070..d4e86034 100644 --- a/tests/self_join_tests.rs +++ b/tests/self_join_tests.rs @@ -23,7 +23,7 @@ pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> { let model = self_join::Model { uuid: Uuid::new_v4(), uuid_ref: None, - time: Some(Time::from_hms(1, 00, 00)), + time: Some(Time::from_hms_opt(1, 00, 00).unwrap()), }; model.clone().into_active_model().insert(db).await?; @@ -31,7 +31,7 @@ pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> { let linked_model = self_join::Model { uuid: Uuid::new_v4(), uuid_ref: Some(model.clone().uuid), - time: Some(Time::from_hms(2, 00, 00)), + time: Some(Time::from_hms_opt(2, 00, 00).unwrap()), }; linked_model.clone().into_active_model().insert(db).await?; @@ -39,7 +39,7 @@ pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> { let not_linked_model = self_join::Model { uuid: Uuid::new_v4(), uuid_ref: None, - time: Some(Time::from_hms(3, 00, 00)), + time: Some(Time::from_hms_opt(3, 00, 00).unwrap()), }; not_linked_model diff --git a/tests/uuid_tests.rs b/tests/uuid_tests.rs index 20df5085..b0d07772 100644 --- a/tests/uuid_tests.rs +++ b/tests/uuid_tests.rs @@ -28,8 +28,8 @@ pub async fn insert_metadata(db: &DatabaseConnection) -> Result<(), DbErr> { key: "markup".to_owned(), value: "1.18".to_owned(), bytes: vec![1, 2, 3], - date: Some(Date::from_ymd(2021, 9, 27)), - time: Some(Time::from_hms(11, 32, 55)), + date: Some(Date::from_ymd_opt(2021, 9, 27).unwrap()), + time: Some(Time::from_hms_opt(11, 32, 55).unwrap()), }; let result = metadata.clone().into_active_model().insert(db).await?; @@ -65,8 +65,8 @@ pub async fn create_and_update_metadata(db: &DatabaseConnection) -> Result<(), D key: "markup".to_owned(), value: "1.18".to_owned(), bytes: vec![1, 2, 3], - date: Some(Date::from_ymd(2021, 9, 27)), - time: Some(Time::from_hms(11, 32, 55)), + date: Some(Date::from_ymd_opt(2021, 9, 27).unwrap()), + time: Some(Time::from_hms_opt(11, 32, 55).unwrap()), }; let res = Metadata::insert(metadata.clone().into_active_model())