Skip to content

Commit

Permalink
review(borngraced): refactor get_utc_timestamp with test code
Browse files Browse the repository at this point in the history
  • Loading branch information
dimxy committed Dec 29, 2024
1 parent 5be3e5c commit 6eaa3cf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions mm2src/common/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,16 +1080,16 @@ impl<Id> Default for PagingOptionsEnum<Id> {
}

#[inline(always)]
#[cfg(not(feature = "for-tests"))]
pub fn get_utc_timestamp() -> i64 { Utc::now().timestamp() }

/// get_utc_timestamp for tests allowing to add some bias to 'now'
#[cfg(feature = "for-tests")]
pub fn get_utc_timestamp() -> i64 {
Utc::now().timestamp()
// get_utc_timestamp for tests allowing to add some bias to 'now'
#[cfg(feature = "for-tests")]
return Utc::now().timestamp()
+ std::env::var("TEST_TIMESTAMP_OFFSET")
.map(|s| s.as_str().parse::<i64>().unwrap_or_default())
.unwrap_or_default()
.unwrap_or_default();

#[cfg(not(feature = "for-tests"))]
return Utc::now().timestamp();
}

#[inline(always)]
Expand Down

0 comments on commit 6eaa3cf

Please sign in to comment.