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

Function update

tests/graph/integration/postgres/entity.rs:195–432  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

193#[tokio::test]
194#[expect(clippy::too_many_lines)]
195async fn update() {
196 let page_v1: PropertyObject =
197 serde_json::from_str(entity::PAGE_V1).expect("could not parse entity");
198 let page_v2: PropertyObject =
199 serde_json::from_str(entity::PAGE_V2).expect("could not parse entity");
200
201 let mut database = DatabaseTestWrapper::new().await;
202 let mut api = database
203 .seed(
204 [data_type::VALUE_V1, data_type::TEXT_V1],
205 [property_type::TEXT_V1],
206 [entity_type::PAGE_V1],
207 )
208 .await
209 .expect("could not seed database:");
210
211 let v1_entity = api
212 .create_entity(
213 api.account_id,
214 CreateEntityParams {
215 web_id: WebId::new(api.account_id),
216 entity_uuid: None,
217 decision_time: None,
218 entity_type_ids: HashSet::from([VersionedUrl {
219 base_url: BaseUrl::new(
220 "https://blockprotocol.org/@alice/types/entity-type/page/".to_owned(),
221 )
222 .expect("couldn't construct Base URL"),
223 version: OntologyTypeVersion {
224 major: 1,
225 pre_release: None,
226 },
227 }]),
228 properties: PropertyObjectWithMetadata::from_parts(page_v1.clone(), None)
229 .expect("could not create property with metadata object"),
230 confidence: None,
231 link_data: None,
232 draft: false,
233 policies: Vec::new(),
234 provenance: ProvidedEntityEditionProvenance {
235 actor_type: ActorType::User,
236 origin: OriginProvenance::from_empty_type(OriginType::Api),
237 sources: Vec::new(),
238 },
239 read_only: false,
240 },
241 )
242 .await
243 .expect("could not create entity");
244
245 let v2_entity = api
246 .patch_entity(
247 api.account_id,
248 PatchEntityParams {
249 entity_id: v1_entity.metadata.record_id.entity_id,
250 properties: vec![PropertyPatchOperation::Replace {
251 path: PropertyPath::default(),
252 property: PropertyWithMetadata::from_parts(

Callers

nothing calls this directly

Calls 15

allFunction · 0.85
create_entityMethod · 0.80
unwrapMethod · 0.80
startMethod · 0.65
popMethod · 0.65
fromFunction · 0.50
for_entity_by_entity_idFunction · 0.50
expectMethod · 0.45
seedMethod · 0.45
to_ownedMethod · 0.45
cloneMethod · 0.45
patch_entityMethod · 0.45

Tested by

no test coverage detected