refactor: replace direct file existence checks with test helpers
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::tests::common::test_helpers::{create_temp_dir, create_empty_temp_file};
|
use crate::tests::common::test_helpers::{create_temp_dir, create_empty_temp_file, assert_file_exists};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_mode_setup() {
|
fn test_delete_mode_setup() {
|
||||||
@@ -15,6 +15,6 @@ mod tests {
|
|||||||
let test_file = create_empty_temp_file(&temp_dir, "test_delete.txt");
|
let test_file = create_empty_temp_file(&temp_dir, "test_delete.txt");
|
||||||
|
|
||||||
// Verify file exists before deletion test
|
// Verify file exists before deletion test
|
||||||
assert!(test_file.exists());
|
assert_file_exists(&test_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::tests::common::test_helpers::{create_temp_dir, test_temp_dir_setup};
|
use crate::tests::common::test_helpers::{create_temp_dir, test_temp_dir_setup, assert_file_not_exists};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_mode_basic_setup() {
|
fn test_get_mode_basic_setup() {
|
||||||
@@ -14,6 +14,6 @@ mod tests {
|
|||||||
let test_file = temp_dir.path().join("test_get.txt");
|
let test_file = temp_dir.path().join("test_get.txt");
|
||||||
|
|
||||||
// Test path creation
|
// Test path creation
|
||||||
assert!(!test_file.exists());
|
assert_file_not_exists(&test_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::tests::common::test_helpers::{create_temp_dir, test_file_creation};
|
use crate::tests::common::test_helpers::{create_temp_dir, test_file_creation, assert_file_not_exists, get_file_size};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -11,8 +11,7 @@ mod tests {
|
|||||||
let file_path = test_file_creation(&dir, "info_test.txt", content);
|
let file_path = test_file_creation(&dir, "info_test.txt", content);
|
||||||
|
|
||||||
// Additional verification specific to info mode
|
// Additional verification specific to info mode
|
||||||
let metadata = std::fs::metadata(&file_path).expect("Failed to get file metadata");
|
assert!(get_file_size(&file_path) > 0);
|
||||||
assert!(metadata.len() > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -21,6 +20,6 @@ mod tests {
|
|||||||
let nonexistent_path = PathBuf::from("/nonexistent/file/path.txt");
|
let nonexistent_path = PathBuf::from("/nonexistent/file/path.txt");
|
||||||
|
|
||||||
// Verify the file doesn't exist
|
// Verify the file doesn't exist
|
||||||
assert!(!nonexistent_path.exists());
|
assert_file_not_exists(&nonexistent_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::tests::common::test_helpers::{create_temp_dir, create_temp_file_with_content, create_empty_temp_file};
|
use crate::tests::common::test_helpers::{create_temp_dir, create_temp_file_with_content, create_empty_temp_file, assert_file_exists, get_file_size};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_save_mode_basic_functionality() {
|
fn test_save_mode_basic_functionality() {
|
||||||
@@ -9,7 +9,7 @@ mod tests {
|
|||||||
let file_path = create_temp_file_with_content(&dir, "test_input.txt", "test content for save mode\n");
|
let file_path = create_temp_file_with_content(&dir, "test_input.txt", "test content for save mode\n");
|
||||||
|
|
||||||
// Verify file was created
|
// Verify file was created
|
||||||
assert!(file_path.exists());
|
assert_file_exists(&file_path);
|
||||||
|
|
||||||
// Note: Actual save mode testing would require integration with the keep database
|
// Note: Actual save mode testing would require integration with the keep database
|
||||||
// and compression engines, which is complex for unit tests
|
// and compression engines, which is complex for unit tests
|
||||||
@@ -22,8 +22,7 @@ mod tests {
|
|||||||
let file_path = create_empty_temp_file(&dir, "empty_test.txt");
|
let file_path = create_empty_temp_file(&dir, "empty_test.txt");
|
||||||
|
|
||||||
// Verify empty file was created
|
// Verify empty file was created
|
||||||
assert!(file_path.exists());
|
assert_file_exists(&file_path);
|
||||||
let metadata = std::fs::metadata(&file_path).expect("Failed to get file metadata");
|
assert_eq!(get_file_size(&file_path), 0);
|
||||||
assert_eq!(metadata.len(), 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user