()
| 358 | |
| 359 | #[test] |
| 360 | fn format() { |
| 361 | // Test stdin formatting |
| 362 | assert_cmd_snapshot!(prqlc_command().args(["fmt"]).pass_stdin("from tracks | take 20"), @" |
| 363 | success: true |
| 364 | exit_code: 0 |
| 365 | ----- stdout ----- |
| 366 | from tracks |
| 367 | take 20 |
| 368 | |
| 369 | ----- stderr ----- |
| 370 | "); |
| 371 | |
| 372 | // Test formatting a path: |
| 373 | |
| 374 | // Create a temporary directory |
| 375 | let temp_dir = TempDir::new().expect("Failed to create temp directory"); |
| 376 | |
| 377 | // Copy files from project_path() to temp_dir |
| 378 | copy_dir(&project_path(), temp_dir.path()); |
| 379 | |
| 380 | // Run fmt command on the temp directory |
| 381 | let _result = prqlc_command() |
| 382 | .args(["fmt", temp_dir.path().to_str().unwrap()]) |
| 383 | .status() |
| 384 | .unwrap(); |
| 385 | |
| 386 | // Check if files in temp_dir match the original files |
| 387 | compare_directories(&project_path(), temp_dir.path()); |
| 388 | } |
| 389 | |
| 390 | fn copy_dir(src: &Path, dst: &Path) { |
| 391 | for entry in WalkDir::new(src) { |
no test coverage detected