Skip to content

Commit

Permalink
Update Rust crate time to v0.3.37 (#5787)
Browse files Browse the repository at this point in the history
Co-authored-by: hash-worker[bot] <180894564+hash-worker[bot]@users.noreply.github.com>
Co-authored-by: Tim Diekmann <21277928+TimDiekmann@users.noreply.github.com>
Co-authored-by: Tim Diekmann <post@timdiekmann.de>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent 42c1bfa commit f66015e
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 46 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ sentry-types = { version = "=0.35.0", default-features = false }
serde = { version = "=1.0.215", default-features = false }
serde_json = { version = "=1.0.133" }
text-size = { version = "=1.1.1", default-features = false }
time = { version = "=0.3.36", default-features = false }
time = { version = "=0.3.37", default-features = false }
tokio = { version = "=1.42.0", default-features = false }
tokio-postgres = { version = "=0.7.12", default-features = false }
tokio-util = { version = "=0.7.13", default-features = false }
Expand Down
10 changes: 9 additions & 1 deletion libs/@local/graph/temporal-versioning/src/timestamp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(feature = "postgres")]
use core::error::Error;
use core::{fmt, marker::PhantomData, str::FromStr};
use core::{fmt, marker::PhantomData, ops::Sub, str::FromStr};

#[cfg(feature = "postgres")]
use bytes::BytesMut;
Expand Down Expand Up @@ -93,6 +93,14 @@ impl<A> Timestamp<A> {
}
}

impl<T> Sub for Timestamp<T> {
type Output = time::Duration;

fn sub(self, rhs: Self) -> Self::Output {
self.time - rhs.time
}
}

impl<A> FromStr for Timestamp<A> {
type Err = time::error::Parse;

Expand Down
111 changes: 71 additions & 40 deletions tests/graph/integration/postgres/drafts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use hash_graph_types::{
owned_by_id::OwnedById,
};
use pretty_assertions::assert_eq;
use time::Duration;
use type_system::url::{BaseUrl, OntologyTypeVersion, VersionedUrl};

use crate::{DatabaseApi, DatabaseTestWrapper};
Expand Down Expand Up @@ -326,21 +327,27 @@ async fn no_initial_draft() {
);
assert!(check_entity_exists(&api, entity.metadata.record_id.entity_id).await);
assert!(check_entity_exists(&api, updated_entity.metadata.record_id.entity_id).await);
assert_eq!(
updated_entity
assert!(
(updated_entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_transaction_time,
Some(*undraft_transaction_time)
.first_non_draft_created_at_transaction_time
.expect("transaction time should be set")
- *undraft_transaction_time)
.abs()
< Duration::milliseconds(1)
);
assert_eq!(
updated_entity
assert!(
(updated_entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_decision_time,
Some(*undraft_decision_time)
.first_non_draft_created_at_decision_time
.expect("decision time should be set")
- *undraft_decision_time)
.abs()
< Duration::milliseconds(1)
);

let updated_live_entity = api
Expand Down Expand Up @@ -375,21 +382,27 @@ async fn no_initial_draft() {
);
assert!(!check_entity_exists(&api, updated_entity.metadata.record_id.entity_id).await);
assert!(check_entity_exists(&api, updated_live_entity.metadata.record_id.entity_id).await);
assert_eq!(
updated_live_entity
assert!(
(updated_live_entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_transaction_time,
Some(*undraft_transaction_time)
.first_non_draft_created_at_transaction_time
.expect("transaction time should be set")
- *undraft_transaction_time)
.abs()
< Duration::milliseconds(1)
);
assert_eq!(
updated_live_entity
assert!(
(updated_live_entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_decision_time,
Some(*undraft_decision_time)
.first_non_draft_created_at_decision_time
.expect("decision time should be set")
- *undraft_decision_time)
.abs()
< Duration::milliseconds(1)
);
}
}
Expand Down Expand Up @@ -422,21 +435,27 @@ async fn multiple_drafts() {
entity.metadata.temporal_versioning.transaction_time.start();
let ClosedTemporalBound::Inclusive(undraft_decision_time) =
entity.metadata.temporal_versioning.decision_time.start();
assert_eq!(
entity
assert!(
(entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_transaction_time,
Some(*undraft_transaction_time)
.first_non_draft_created_at_transaction_time
.expect("transaction time should be set")
- *undraft_transaction_time)
.abs()
< Duration::milliseconds(1)
);
assert_eq!(
entity
assert!(
(entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_decision_time,
Some(*undraft_decision_time)
.first_non_draft_created_at_decision_time
.expect("decision time should be set")
- *undraft_decision_time)
.abs()
< Duration::milliseconds(1)
);

let mut drafts = Vec::new();
Expand Down Expand Up @@ -477,21 +496,27 @@ async fn multiple_drafts() {
);
assert!(check_entity_exists(&api, entity.metadata.record_id.entity_id).await);
assert!(check_entity_exists(&api, updated_entity.metadata.record_id.entity_id).await);
assert_eq!(
updated_entity
assert!(
(updated_entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_transaction_time,
Some(*undraft_transaction_time)
.first_non_draft_created_at_transaction_time
.expect("transaction time should be set")
- *undraft_transaction_time)
.abs()
< Duration::milliseconds(1)
);
assert_eq!(
updated_entity
assert!(
(updated_entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_decision_time,
Some(*undraft_decision_time)
.first_non_draft_created_at_decision_time
.expect("decision time should be set")
- *undraft_decision_time)
.abs()
< Duration::milliseconds(1)
);
drafts.push(updated_entity.metadata.record_id.entity_id);
}
Expand Down Expand Up @@ -522,21 +547,27 @@ async fn multiple_drafts() {
assert!(!check_entity_exists(&api, draft).await);
assert!(check_entity_exists(&api, updated_live_entity.metadata.record_id.entity_id).await);

assert_eq!(
updated_live_entity
assert!(
(updated_live_entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_transaction_time,
Some(*undraft_transaction_time)
.first_non_draft_created_at_transaction_time
.expect("transaction time should be set")
- *undraft_transaction_time)
.abs()
< Duration::milliseconds(1)
);
assert_eq!(
updated_live_entity
assert!(
(updated_live_entity
.metadata
.provenance
.inferred
.first_non_draft_created_at_decision_time,
Some(*undraft_decision_time)
.first_non_draft_created_at_decision_time
.expect("decision time should be set")
- *undraft_decision_time)
.abs()
< Duration::milliseconds(1)
);
}
}

0 comments on commit f66015e

Please sign in to comment.