+
+
+ #[test]
+ fn create_a_new_recipe_then_update_its_title() -> Result<()> {
+ let connection = Connection::new_in_memory()?;
+
+ connection.execute_sql(
+ "INSERT INTO [User] ([id], [email], [name], [password], [creation_datetime], [validation_token]) VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
+ params![
+ 1,
+ "paul@atreides.com",
+ "paul",
+ "$argon2id$v=19$m=4096,t=3,p=1$G4fjepS05MkRbTqEImUdYg$GGziE8uVQe1L1oFHk37lBno10g4VISnVqynSkLCH3Lc",
+ "2022-11-29 22:05:04.121407300+00:00",
+ Value::Null,
+ ]
+ )?;
+
+ match connection.create_recipe(2) {
+ Err(DBError::SqliteError(Error::SqliteFailure(ffi::Error { code: ErrorCode::ConstraintViolation, extended_code: _ }, Some(_)))) => (), // Nominal case.
+ other => panic!("Creating a recipe with an inexistant user must fail: {:?}", other),
+ }
+
+ let recipe_id = connection.create_recipe(1)?;
+ assert_eq!(recipe_id, 1);
+
+ connection.set_recipe_title(recipe_id, "Crêpe")?;
+
+ let recipe = connection.get_recipe(recipe_id)?;
+ assert_eq!(recipe.title, "Crêpe".to_string());
+
+ Ok(())
+ }