-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better Integration for Testing #46
Comments
Is there a good approach that does not impose test-related complexity on regular users? I'd be all for it. |
Good questions, I believe the best approach might be to have two versions of the API.
pub trait DirsLocator {
fn home_dir() -> Option<PathBuf>;
fn cache_dir() -> Option<PathBuf>;
fn config_dir() -> Option<PathBuf>;
fn data_dir() -> Option<PathBuf>;
fn data_local_dir() -> Option<PathBuf>;
fn executable_dir() -> Option<PathBuf>;
fn preference_dir() -> Option<PathBuf>;
fn runtime_dir() -> Option<PathBuf>;
fn state_dir() -> Option<PathBuf>;
fn audio_dir() -> Option<PathBuf>;
fn desktop_dir() -> Option<PathBuf>;
fn document_dir() -> Option<PathBuf>;
fn download_dir() -> Option<PathBuf>;
fn font_dir() -> Option<PathBuf>;
fn picture_dir() -> Option<PathBuf>;
fn public_dir() -> Option<PathBuf>;
fn template_dir() -> Option<PathBuf>;
fn video_dir() -> Option<PathBuf>;
}
struct Dirs;
impl DirsLocator for Dirs {
fn home_dir() -> Option<PathBuf> {
sys::home_dir()
}
fn cache_dir() -> Option<PathBuf> {
sys::cache_dir()
}
fn config_dir() -> Option<PathBuf> {
sys::config_dir()
}
fn data_dir() -> Option<PathBuf> {
sys::data_dir()
}
fn data_local_dir() -> Option<PathBuf> {
sys::data_local_dir()
}
fn executable_dir() -> Option<PathBuf> {
sys::executable_dir()
}
fn preference_dir() -> Option<PathBuf> {
sys::preference_dir()
}
fn runtime_dir() -> Option<PathBuf> {
sys::runtime_dir()
}
fn state_dir() -> Option<PathBuf> {
sys::state_dir()
}
fn audio_dir() -> Option<PathBuf> {
sys::audio_dir()
}
fn desktop_dir() -> Option<PathBuf> {
sys::desktop_dir()
}
fn document_dir() -> Option<PathBuf> {
sys::document_dir()
}
fn download_dir() -> Option<PathBuf> {
sys::download_dir()
}
fn font_dir() -> Option<PathBuf> {
sys::font_dir()
}
fn picture_dir() -> Option<PathBuf> {
sys::picture_dir()
}
fn public_dir() -> Option<PathBuf> {
sys::public_dir()
}
fn template_dir() -> Option<PathBuf> {
sys::template_dir()
}
fn video_dir() -> Option<PathBuf> {
sys::video_dir()
}
} |
Maybe this could just check for an env before running |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Love the project but kinda of a pain to write tests around code that is leveraging this library. Have the team considered making a trait of the Public API's so they can be mocked or replaced with an in memory file system for testing code that uses this library.
The text was updated successfully, but these errors were encountered: