diff options
Diffstat (limited to 'tests/common')
| -rw-r--r-- | tests/common/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs index d1c07a4..5c48923 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -128,6 +128,23 @@ impl Env { self.cfg.hooks.shim_fail = Some(tool.to_string()); } + /// Run a statement the library deliberately does not expose. + /// + /// Fixtures use this to put a row in a state production would take a long + /// way to reach — forcing a risk level, say — rather than the library + /// growing a public setter that exists only for tests. + pub fn execute(&self, sql: &str, params: &[P]) { + let c = rusqlite::Connection::open(self.cfg.db_path()).unwrap(); + let refs: Vec<&dyn rusqlite::ToSql> = params + .iter() + .map(|p| match p { + P::I(i) => i as &dyn rusqlite::ToSql, + P::S(s) => s as &dyn rusqlite::ToSql, + }) + .collect(); + c.execute(sql, rusqlite::params_from_iter(refs)).unwrap(); + } + pub fn query_i64(&self, sql: &str, params: &[P]) -> Option<i64> { let sql = sql.to_string(); let params: Vec<P> = params.to_vec(); |
