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

Function no_initial_draft

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

Source from the content-addressed store, hash-verified

270#[tokio::test]
271#[expect(clippy::too_many_lines)]
272async fn no_initial_draft() {
273 let mut database = DatabaseTestWrapper::new().await;
274 let mut api = seed(&mut database).await;
275
276 let entity = api
277 .create_entity(
278 api.account_id,
279 CreateEntityParams {
280 web_id: WebId::new(api.account_id),
281 entity_uuid: None,
282 decision_time: None,
283 entity_type_ids: HashSet::from([person_entity_type_id()]),
284 properties: PropertyObjectWithMetadata::from_parts(alice(), None)
285 .expect("could not create property with metadata object"),
286 confidence: None,
287 link_data: None,
288 draft: false,
289 policies: Vec::new(),
290 provenance: ProvidedEntityEditionProvenance {
291 actor_type: ActorType::User,
292 origin: OriginProvenance::from_empty_type(OriginType::Api),
293 sources: Vec::new(),
294 },
295 read_only: false,
296 },
297 )
298 .await
299 .expect("could not create entity");
300 assert!(entity.metadata.record_id.entity_id.draft_id.is_none());
301 assert!(check_entity_exists(&api, entity.metadata.record_id.entity_id).await);
302
303 let ClosedTemporalBound::Inclusive(undraft_transaction_time) =
304 entity.metadata.temporal_versioning.transaction_time.start();
305 let ClosedTemporalBound::Inclusive(undraft_decision_time) =
306 entity.metadata.temporal_versioning.decision_time.start();
307 assert_eq!(
308 entity
309 .metadata
310 .provenance
311 .inferred
312 .first_non_draft_created_at_transaction_time,
313 Some(*undraft_transaction_time)
314 );
315 assert_eq!(
316 entity
317 .metadata
318 .provenance
319 .inferred
320 .first_non_draft_created_at_decision_time,
321 Some(*undraft_decision_time)
322 );
323
324 for _ in 0..5 {
325 let updated_entity = api
326 .patch_entity(
327 api.account_id,
328 PatchEntityParams {
329 entity_id: entity.metadata.record_id.entity_id,

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected