Initialize database via CLI
()
| 22 | impl CliFixture { |
| 23 | /// Initialize database via CLI |
| 24 | pub fn empty() -> Result<Self, Box<dyn std::error::Error>> { |
| 25 | let temp_dir = tempfile::tempdir()?; |
| 26 | let db_path = temp_dir.path().join("graphlite"); |
| 27 | let admin_user = "admin".to_string(); |
| 28 | let admin_password = "test_password_123".to_string(); |
| 29 | |
| 30 | // Initialize database via CLI: cargo run --bin graphlite -- install |
| 31 | let output = Command::new("cargo") |
| 32 | .args([ |
| 33 | "run", |
| 34 | "--quiet", |
| 35 | "--package", |
| 36 | "gql-cli", |
| 37 | "--bin", |
| 38 | "graphlite", |
| 39 | "--", |
| 40 | "install", |
| 41 | ]) |
| 42 | .arg("--path") |
| 43 | .arg(&db_path) |
| 44 | .arg("--admin-user") |
| 45 | .arg(&admin_user) |
| 46 | .arg("--admin-password") |
| 47 | .arg(&admin_password) |
| 48 | .arg("--yes") |
| 49 | .env("RUST_LOG", "error") // Suppress INFO logs in CLI output |
| 50 | .output()?; |
| 51 | |
| 52 | if !output.status.success() { |
| 53 | return Err(format!( |
| 54 | "Install failed: {}", |
| 55 | String::from_utf8_lossy(&output.stderr) |
| 56 | ) |
| 57 | .into()); |
| 58 | } |
| 59 | |
| 60 | Ok(Self { |
| 61 | _temp_dir: temp_dir, |
| 62 | db_path, |
| 63 | admin_user, |
| 64 | admin_password, |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | /// Execute query via CLI and expect success |
| 69 | pub fn assert_query_succeeds(&self, query: &str) -> CliQueryResult { |