()
| 8 | |
| 9 | #[test] |
| 10 | fn all_cli_flags_postgres_with_empty_config() -> Result<(), Box<dyn std::error::Error>> { |
| 11 | // SETUP |
| 12 | let demo_path = current_dir().unwrap().join("tests/sample"); |
| 13 | let sample_query_path = demo_path.join("sample.queries.ts"); |
| 14 | let dir = tempdir()?; |
| 15 | let parent_path = dir.path(); |
| 16 | let config_file_path = parent_path.join(".sqlxrc.json"); |
| 17 | |
| 18 | if sample_query_path.exists() { |
| 19 | fs::remove_file(&sample_query_path)?; |
| 20 | } |
| 21 | let mut temp_file = fs::File::create(&config_file_path)?; |
| 22 | let config_content = r#"{}"#; |
| 23 | writeln!(temp_file, "{config_content}")?; |
| 24 | |
| 25 | // EXECUTE |
| 26 | let mut cmd = cargo_bin_cmd!("sqlx-ts"); |
| 27 | cmd |
| 28 | .arg(demo_path.to_str().unwrap()) |
| 29 | .arg("--ext=ts") |
| 30 | .arg(format!("--config={}", config_file_path.to_str().unwrap())) |
| 31 | .arg("--db-type=postgres") |
| 32 | .arg("--db-host=127.0.0.1") |
| 33 | .arg("--db-port=54321") |
| 34 | .arg("--db-user=postgres") |
| 35 | .arg("--db-pass=postgres") |
| 36 | .arg("--db-name=postgres") |
| 37 | .arg("-g"); |
| 38 | |
| 39 | cmd.assert().failure().stderr(predicates::str::contains( |
| 40 | "Empty or invalid JSON provided for file based configuration - config file:", |
| 41 | )); |
| 42 | |
| 43 | assert!(!sample_query_path.exists()); |
| 44 | Ok(()) |
| 45 | } |
| 46 | |
| 47 | #[test] |
| 48 | fn all_cli_flags_mysql_with_empty_config() -> Result<(), Box<dyn std::error::Error>> { |
nothing calls this directly
no outgoing calls
no test coverage detected