(
&mut self,
data_types: D,
property_types: P,
entity_types: E,
)
| 204 | |
| 205 | impl DatabaseTestWrapper { |
| 206 | pub async fn seed<D, P, E>( |
| 207 | &mut self, |
| 208 | data_types: D, |
| 209 | property_types: P, |
| 210 | entity_types: E, |
| 211 | ) -> Result<DatabaseApi<'_>, Report<InsertionError>> |
| 212 | where |
| 213 | D: IntoIterator<Item = &'static str, IntoIter: Send> + Send, |
| 214 | P: IntoIterator<Item = &'static str, IntoIter: Send> + Send, |
| 215 | E: IntoIterator<Item = &'static str, IntoIter: Send> + Send, |
| 216 | { |
| 217 | let mut store = self |
| 218 | .connection |
| 219 | .transaction() |
| 220 | .await |
| 221 | .expect("could not start test transaction"); |
| 222 | |
| 223 | store |
| 224 | .seed_system_policies() |
| 225 | .await |
| 226 | .expect("Should be able to seed system policies"); |
| 227 | |
| 228 | let system_account_id = store |
| 229 | .get_or_create_system_machine("h") |
| 230 | .await |
| 231 | .change_context(InsertionError)?; |
| 232 | let user_id = store |
| 233 | .create_user_actor( |
| 234 | system_account_id.into(), |
| 235 | CreateUserActorParams { |
| 236 | user_id: None, |
| 237 | shortname: Some("bench-user".to_owned()), |
| 238 | registration_complete: true, |
| 239 | }, |
| 240 | ) |
| 241 | .await |
| 242 | .change_context(InsertionError)? |
| 243 | .user_id; |
| 244 | |
| 245 | store |
| 246 | .create_data_types( |
| 247 | user_id.into(), |
| 248 | data_types.into_iter().map(|data_type_str| { |
| 249 | let schema: DataType = serde_json::from_str(data_type_str) |
| 250 | .expect("could not parse data type representation"); |
| 251 | CreateDataTypeParams { |
| 252 | schema, |
| 253 | ownership: OntologyOwnership::Local { |
| 254 | web_id: user_id.into(), |
| 255 | }, |
| 256 | conflict_behavior: ConflictBehavior::Skip, |
| 257 | provenance: ProvidedOntologyEditionProvenance { |
| 258 | actor_type: ActorType::User, |
| 259 | origin: OriginProvenance::from_empty_type(OriginType::Api), |
| 260 | sources: Vec::new(), |
| 261 | }, |
| 262 | conversions: HashMap::new(), |
| 263 | } |
no test coverage detected