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

Function insert

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

Source from the content-addressed store, hash-verified

29
30#[tokio::test]
31async fn insert() {
32 let person: PropertyObject =
33 serde_json::from_str(entity::PERSON_ALICE_V1).expect("could not parse entity");
34
35 let mut database = DatabaseTestWrapper::new().await;
36 let mut api = database
37 .seed(
38 [
39 data_type::VALUE_V1,
40 data_type::TEXT_V1,
41 data_type::NUMBER_V1,
42 ],
43 [
44 property_type::NAME_V1,
45 property_type::AGE_V1,
46 property_type::FAVORITE_SONG_V1,
47 property_type::FAVORITE_FILM_V1,
48 property_type::HOBBY_V1,
49 property_type::INTERESTS_V1,
50 ],
51 [
52 entity_type::LINK_V1,
53 entity_type::link::FRIEND_OF_V1,
54 entity_type::link::ACQUAINTANCE_OF_V1,
55 entity_type::PERSON_V1,
56 ],
57 )
58 .await
59 .expect("could not seed database");
60
61 let entity = api
62 .create_entity(
63 api.account_id,
64 CreateEntityParams {
65 web_id: WebId::new(api.account_id),
66 entity_uuid: None,
67 decision_time: None,
68 entity_type_ids: HashSet::from([VersionedUrl {
69 base_url: BaseUrl::new(
70 "https://blockprotocol.org/@alice/types/entity-type/person/".to_owned(),
71 )
72 .expect("couldn't construct Base URL"),
73 version: OntologyTypeVersion {
74 major: 1,
75 pre_release: None,
76 },
77 }]),
78 properties: PropertyObjectWithMetadata::from_parts(person.clone(), None)
79 .expect("could not create property with metadata object"),
80 confidence: None,
81 link_data: None,
82 draft: false,
83 policies: Vec::new(),
84 provenance: ProvidedEntityEditionProvenance {
85 actor_type: ActorType::User,
86 origin: OriginProvenance::from_empty_type(OriginType::Api),
87 sources: Vec::new(),
88 },

Callers

nothing calls this directly

Calls 9

allFunction · 0.85
create_entityMethod · 0.80
fromFunction · 0.50
for_entity_by_entity_idFunction · 0.50
expectMethod · 0.45
seedMethod · 0.45
to_ownedMethod · 0.45
cloneMethod · 0.45
query_entitiesMethod · 0.45

Tested by

no test coverage detected