Skip to main content

insert

Function insert 

Source
pub fn insert(table: &str, values: &[(&str, Value)]) -> i64
Expand description

Inserts a row into table of the test database and returns its id: what generated factories (tests/factories/) call. One wrangler call (about a second).

§Panics

Like sql, e.g. on a constraint violation.

§Examples

use ocre::serde_json::json;

let id = ocre::testing::insert("posts", &[("title", json!("Hello")), ("published", json!(true))]);
assert!(id > 0);