From 22bf4bf135423158fe8419ac9763ae26472f1d43 Mon Sep 17 00:00:00 2001 From: unclekingpin Date: Sun, 22 Oct 2023 02:11:54 -0700 Subject: [PATCH 1/2] use unix epoch as default time for NotificationsBucket created --- src/types/notifications/notifications_bucket.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/notifications/notifications_bucket.rs b/src/types/notifications/notifications_bucket.rs index 957042e41..8b49f5384 100644 --- a/src/types/notifications/notifications_bucket.rs +++ b/src/types/notifications/notifications_bucket.rs @@ -25,7 +25,7 @@ pub struct NotificationsBucket { #[serde(default)] pub last_updated: Option>, /// The moment that the notification bucket was initialized. - #[derivative(Default(value = "Utc::now()"))] + #[derivative(Default(value = "Utc.timestamp_opt(0, 0).unwrap()"))] pub created: DateTime, } From ce3b956d8a69712d55a34c2e7ebd413863107880 Mon Sep 17 00:00:00 2001 From: unclekingpin Date: Sun, 22 Oct 2023 04:48:37 -0700 Subject: [PATCH 2/2] remove Default from Ctx --- src/models/ctx/ctx.rs | 12 ++++++++---- src/types/notifications/notifications_bucket.rs | 9 +++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/models/ctx/ctx.rs b/src/models/ctx/ctx.rs index c8be16888..3c67176c2 100644 --- a/src/models/ctx/ctx.rs +++ b/src/models/ctx/ctx.rs @@ -16,6 +16,7 @@ use crate::types::profile::{Auth, AuthKey, Profile}; use crate::types::resource::MetaItem; use crate::types::streams::StreamsBucket; +#[cfg(test)] use derivative::Derivative; use enclose::enclose; use futures::{future, FutureExt, TryFutureExt}; @@ -30,8 +31,9 @@ pub enum CtxStatus { Ready, } -#[derive(Derivative, Serialize, Deserialize, Clone, Debug)] -#[derivative(Default)] +#[derive(Serialize, Deserialize, Clone, Debug)] +#[cfg_attr(test, derive(Derivative))] +#[cfg_attr(test, derivative(Default))] pub struct Ctx { pub profile: Profile, // TODO SubtitlesBucket @@ -42,7 +44,7 @@ pub struct Ctx { #[serde(skip)] pub streams: StreamsBucket, #[serde(skip)] - #[derivative(Default(value = "CtxStatus::Ready"))] + #[cfg_attr(test, derivative(Default(value = "CtxStatus::Ready")))] pub status: CtxStatus, #[serde(skip)] /// Used only for loading the Descriptor and then the descriptor will be discarded @@ -63,7 +65,9 @@ impl Ctx { library, streams, notifications, - ..Self::default() + trakt_addon: None, + notification_catalogs: vec![], + status: CtxStatus::Ready, } } } diff --git a/src/types/notifications/notifications_bucket.rs b/src/types/notifications/notifications_bucket.rs index 8b49f5384..5efd3a5e0 100644 --- a/src/types/notifications/notifications_bucket.rs +++ b/src/types/notifications/notifications_bucket.rs @@ -1,6 +1,9 @@ use std::collections::{hash_map::Entry, HashMap}; +#[cfg(test)] +use chrono::offset::TimeZone; use chrono::{DateTime, Utc}; +#[cfg(test)] use derivative::Derivative; use serde::{Deserialize, Serialize}; @@ -13,7 +16,9 @@ use crate::{ }, }; -#[derive(Default, Derivative, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] +#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] +#[cfg_attr(test, derive(Derivative))] +#[cfg_attr(test, derivative(Default))] #[serde(rename_all = "camelCase")] pub struct NotificationsBucket { #[serde(default)] @@ -25,7 +30,7 @@ pub struct NotificationsBucket { #[serde(default)] pub last_updated: Option>, /// The moment that the notification bucket was initialized. - #[derivative(Default(value = "Utc.timestamp_opt(0, 0).unwrap()"))] + #[cfg_attr(test, derivative(Default(value = "Utc.timestamp_opt(0, 0).unwrap()")))] pub created: DateTime, }