Lines
100 %
Functions
50 %
Branches
//! Shared fixtures for the end-to-end form suites (`list_accounts` and its siblings).
use sqlx::PgPool;
use uuid::Uuid;
/// The hook `local_db_sqlx_test` calls before each test body.
pub async fn setup() {}
/// A verified user: the SSH-key write commands refuse a disabled account.
pub async fn insert_test_user(pool: &PgPool, id: Uuid) -> sqlx::Result<()> {
sqlx::query(
"INSERT INTO users (
id, user_name, email, photo, verified, user_password,
user_role, database_name, created_at
) VALUES (
$1, 'rpc-test-user', $1::text || '@example.com', 'default.png',
TRUE, 'irrelevant', 'user', 'rpc-test', NOW()
)",
)
.bind(id)
.execute(pool)
.await?;
Ok(())
}
/// The uuid a single-record write returns as `:value "<uuid>"`.
#[must_use]
pub fn extract_id_field(response: &str, _key: &str) -> Option<String> {
let needle = ":value \"";
let start = response.find(needle)? + needle.len();
let end = start + response[start..].find('"')?;
Some(response[start..end].to_string())