diff --git a/justfile b/justfile index 8f25539..27bf66f 100644 --- a/justfile +++ b/justfile @@ -11,7 +11,7 @@ test: cargo test fmt: - cargo fmt + cargo +nightly fmt watch recipe *args: watchexec --clear -e rs -- just {{ recipe }} {{ args }} diff --git a/src/checks.rs b/src/checks.rs index 18101f8..328a6db 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -1,5 +1,6 @@ -use anyhow::Result; use std::path::Path; + +use anyhow::Result; use thiserror::Error; #[derive(Error, Debug)] @@ -62,11 +63,13 @@ pub(super) fn stow_directory_is_grandchild_of_common_ancestor( #[cfg(test)] mod tests { - use super::*; use std::fs::File; use std::os::unix::fs as unix_fs; + use tempfile::TempDir; + use super::*; + #[test] fn test_stow_directory_is_grandchild_of_common_ancestor() { let common_ancestor = Path::new("/home/user"); diff --git a/src/command_impl.rs b/src/command_impl.rs index b87cba2..db27c63 100644 --- a/src/command_impl.rs +++ b/src/command_impl.rs @@ -1,10 +1,11 @@ //! This module contains the implementions for Commands that execute side effects to modify the //! filesytem. -use anyhow::{Context, Result}; -use fs_extra::dir::CopyOptions; use std::path::{Path, PathBuf}; use std::process::Command as ProcessCommand; +use anyhow::{Context, Result}; +use fs_extra::dir::CopyOptions; + /// Commands to execute side effects to modify the filesystem. #[derive(Debug)] pub(super) enum Command { @@ -104,10 +105,12 @@ impl CommandImpl for Command { #[cfg(test)] mod tests { - use super::*; use std::fs; + use tempfile::TempDir; + use super::*; + #[test] fn test_create_directory() { let temp_dir = TempDir::new().unwrap(); diff --git a/src/main.rs b/src/main.rs index 7a26e9d..f7870fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,17 +70,17 @@ //! ``` //! might be unwanted if the `.config` folder already contains some symlinks that point into the -mod checks; -mod command_impl; -mod util; +use std::path::{Path, PathBuf}; use anyhow::{Context, Result}; use clap::Parser; -use command_impl::Command; -use command_impl::CommandImpl; -use std::path::{Path, PathBuf}; +use command_impl::{Command, CommandImpl}; use util::find_common_ancestor; +mod checks; +mod command_impl; +mod util; + #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { diff --git a/src/util.rs b/src/util.rs index 75c6798..de9adee 100644 --- a/src/util.rs +++ b/src/util.rs @@ -25,9 +25,10 @@ pub(super) fn find_common_ancestor(path1: &Path, path2: &Path) -> PathBuf { #[cfg(test)] mod tests { - use super::*; use std::path::Path; + use super::*; + #[test] fn test_find_common_ancestor_same_path() { let path = Path::new("/home/user/documents");