Execute query via CLI and expect success
(&self, query: &str)
| 67 | |
| 68 | /// Execute query via CLI and expect success |
| 69 | pub fn assert_query_succeeds(&self, query: &str) -> CliQueryResult { |
| 70 | let output = Command::new("cargo") |
| 71 | .args([ |
| 72 | "run", |
| 73 | "--quiet", |
| 74 | "--package", |
| 75 | "gql-cli", |
| 76 | "--bin", |
| 77 | "graphlite", |
| 78 | "--", |
| 79 | "query", |
| 80 | ]) |
| 81 | .arg("--path") |
| 82 | .arg(&self.db_path) |
| 83 | .arg("--user") |
| 84 | .arg(&self.admin_user) |
| 85 | .arg("--password") |
| 86 | .arg(&self.admin_password) |
| 87 | .arg("--format") |
| 88 | .arg("json") |
| 89 | .arg(query) |
| 90 | .env("RUST_LOG", "error") // Suppress INFO logs in CLI output |
| 91 | .output() |
| 92 | .expect("Failed to execute query"); |
| 93 | |
| 94 | if !output.status.success() { |
| 95 | let stderr = String::from_utf8_lossy(&output.stderr); |
| 96 | panic!("Query failed: {}\nQuery: {}", stderr, query); |
| 97 | } |
| 98 | |
| 99 | // Parse JSON output |
| 100 | let stdout = String::from_utf8_lossy(&output.stdout); |
| 101 | CliQueryResult::from_json(&stdout).unwrap_or_else(|e| { |
| 102 | panic!( |
| 103 | "Failed to parse JSON output: {}\nOutput was:\n{}", |
| 104 | e, stdout |
| 105 | ) |
| 106 | }) |
| 107 | } |
| 108 | |
| 109 | /// Execute query via CLI and expect failure |
| 110 | pub fn assert_query_fails(&self, query: &str) -> String { |
no test coverage detected