Skip to content

Commit

Permalink
Fix: Use absolute path in test_empty_input_defaults_to_cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen1 committed Feb 22, 2025
1 parent e040139 commit a0a1b9c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,18 @@ mod integration_tests {
fn test_empty_input_defaults_to_cwd() {
let temp_dir = TempDir::new().unwrap();
let output_dir = temp_dir.path().join("output");
fs::create_dir(&output_dir).unwrap(); // Ensure output directory exists

// Create a file in the current directory (which will be the temp_dir)
let current_dir_file = temp_dir.path().join("current_dir_file.txt");
File::create(&current_dir_file)
.unwrap()
.write_all(b"current dir file content")
.unwrap();

// Change the current directory to the temp_dir
let original_dir = std::env::current_dir().unwrap();
std::env::set_current_dir(&temp_dir).unwrap();

// Use the absolute path of the temp_dir as input
let config = YekConfig::extend_config_with_defaults(
vec![], // Empty input paths
vec![temp_dir.path().to_string_lossy().to_string()], // Use temp_dir as input
output_dir.to_string_lossy().to_string(),
);

Expand All @@ -127,8 +126,7 @@ mod integration_tests {
assert!(output.contains("current dir file content"));
assert_eq!(files.len(), 1);

// Restore the original directory
std::env::set_current_dir(original_dir).unwrap();
// No need to change and restore the directory anymore
}

#[test]
Expand Down

0 comments on commit a0a1b9c

Please sign in to comment.