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

Function initial_draft

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

Source from the content-addressed store, hash-verified

84#[tokio::test]
85#[expect(clippy::too_many_lines)]
86async fn initial_draft() {
87 let mut database = DatabaseTestWrapper::new().await;
88 let mut api = seed(&mut database).await;
89
90 let entity = api
91 .create_entity(
92 api.account_id,
93 CreateEntityParams {
94 web_id: WebId::new(api.account_id),
95 entity_uuid: None,
96 decision_time: None,
97 entity_type_ids: HashSet::from([person_entity_type_id()]),
98 properties: PropertyObjectWithMetadata::from_parts(alice(), None)
99 .expect("could not create property with metadata object"),
100 confidence: None,
101 link_data: None,
102 draft: true,
103 policies: Vec::new(),
104 provenance: ProvidedEntityEditionProvenance {
105 actor_type: ActorType::User,
106 origin: OriginProvenance::from_empty_type(OriginType::Api),
107 sources: Vec::new(),
108 },
109 read_only: false,
110 },
111 )
112 .await
113 .expect("could not create entity");
114 assert!(entity.metadata.record_id.entity_id.draft_id.is_some());
115 assert!(check_entity_exists(&api, entity.metadata.record_id.entity_id).await);
116 assert!(entity.metadata.record_id.entity_id.draft_id.is_some());
117 assert!(
118 entity
119 .metadata
120 .provenance
121 .inferred
122 .first_non_draft_created_at_decision_time
123 .is_none()
124 );
125 assert!(
126 entity
127 .metadata
128 .provenance
129 .inferred
130 .first_non_draft_created_at_transaction_time
131 .is_none()
132 );
133
134 let updated_entity = api
135 .patch_entity(
136 api.account_id,
137 PatchEntityParams {
138 entity_id: entity.metadata.record_id.entity_id,
139 properties: vec![PropertyPatchOperation::Replace {
140 path: PropertyPath::default(),
141 property: PropertyWithMetadata::from_parts(Property::Object(bob()), None)
142 .expect("could not create property with metadata"),
143 }],

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