MCPcopy Create free account
hub / github.com/hashintel/hash / multiple_drafts

Function multiple_drafts

tests/graph/integration/postgres/drafts.rs:460–646  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

458#[tokio::test]
459#[expect(clippy::too_many_lines)]
460async fn multiple_drafts() {
461 let mut database = DatabaseTestWrapper::new().await;
462 let mut api = seed(&mut database).await;
463
464 let entity = api
465 .create_entity(
466 api.account_id,
467 CreateEntityParams {
468 web_id: WebId::new(api.account_id),
469 entity_uuid: None,
470 decision_time: None,
471 entity_type_ids: HashSet::from([person_entity_type_id()]),
472 properties: PropertyObjectWithMetadata::from_parts(alice(), None)
473 .expect("could not create property with metadata object"),
474 confidence: None,
475 link_data: None,
476 draft: false,
477 policies: Vec::new(),
478 provenance: ProvidedEntityEditionProvenance {
479 actor_type: ActorType::User,
480 origin: OriginProvenance::from_empty_type(OriginType::Api),
481 sources: Vec::new(),
482 },
483 read_only: false,
484 },
485 )
486 .await
487 .expect("could not create entity");
488 assert!(entity.metadata.record_id.entity_id.draft_id.is_none());
489 assert!(check_entity_exists(&api, entity.metadata.record_id.entity_id).await);
490 let ClosedTemporalBound::Inclusive(undraft_transaction_time) =
491 entity.metadata.temporal_versioning.transaction_time.start();
492 let ClosedTemporalBound::Inclusive(undraft_decision_time) =
493 entity.metadata.temporal_versioning.decision_time.start();
494 assert!(
495 (entity
496 .metadata
497 .provenance
498 .inferred
499 .first_non_draft_created_at_transaction_time
500 .expect("transaction time should be set")
501 - *undraft_transaction_time)
502 .abs()
503 < Duration::milliseconds(1)
504 );
505 assert!(
506 (entity
507 .metadata
508 .provenance
509 .inferred
510 .first_non_draft_created_at_decision_time
511 .expect("decision time should be set")
512 - *undraft_decision_time)
513 .abs()
514 < Duration::milliseconds(1)
515 );
516
517 let mut drafts = Vec::new();

Callers

nothing calls this directly

Calls 9

create_entityMethod · 0.80
seedFunction · 0.70
person_entity_type_idFunction · 0.70
aliceFunction · 0.70
startMethod · 0.65
pushMethod · 0.65
fromFunction · 0.50
expectMethod · 0.45
patch_entityMethod · 0.45

Tested by

no test coverage detected