MCPcopy Create free account
hub / github.com/PRQL/prql / format

Function format

prqlc/prqlc/src/cli/test.rs:360–388  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

358
359#[test]
360fn 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
390fn copy_dir(src: &Path, dst: &Path) {
391 for entry in WalkDir::new(src) {

Callers 1

compileFunction · 0.85

Calls 4

copy_dirFunction · 0.85
project_pathFunction · 0.85
compare_directoriesFunction · 0.85
prqlc_commandFunction · 0.70

Tested by

no test coverage detected