pub fn sql(query: &str) -> Vec<Map<String, Value>>Expand description
Rows returned by query, run on the test database (Rails’ ActiveRecord::Base.connection.select_all).
It runs the app’s wrangler (node_modules/.bin/wrangler d1 execute DB --local) on TEST_STATE: about a second per call, so keep it to
setup and checks. Several statements may be separated by ;; the rows
of the last one are returned. Values are SQL literals: build them with
quote.
§Panics
When wrangler fails (the message has its output), e.g. on a SQL error.
§Examples
use ocre::testing::{quote, sql};
let rows = sql(&format!("SELECT id FROM posts WHERE title = {}", quote("Hello")));
assert_eq!(rows.len(), 1);