aboutsummaryrefslogtreecommitdiffstats
path: root/crates/common/src/utils.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-07-20 23:44:15 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-07-20 23:44:15 +0200
commit4930f050c56660c245e5976979babb66aea7bfd5 (patch)
tree1a0cc823da65c4258f4434be98e92f814ae4fce2 /crates/common/src/utils.rs
parentchore: Commit (diff)
downloadatuin-4930f050c56660c245e5976979babb66aea7bfd5.zip
chore: Last big refactoring
Diffstat (limited to 'crates/common/src/utils.rs')
-rw-r--r--crates/common/src/utils.rs18
1 files changed, 4 insertions, 14 deletions
diff --git a/crates/common/src/utils.rs b/crates/common/src/utils.rs
index 4451140b..7f46f223 100644
--- a/crates/common/src/utils.rs
+++ b/crates/common/src/utils.rs
@@ -110,14 +110,17 @@ pub fn data_dir() -> PathBuf {
data_dir.join("atuin")
}
+#[must_use]
pub fn runtime_dir() -> PathBuf {
env::var("XDG_RUNTIME_DIR").map_or_else(|_| data_dir(), PathBuf::from)
}
+#[must_use]
pub fn logs_dir() -> PathBuf {
home_dir().join(".atuin").join("logs")
}
+#[must_use]
pub fn get_current_dir() -> String {
// Prefer PWD environment variable over cwd if available to better support symbolic links
env::var("PWD").unwrap_or_else(|_| {
@@ -164,7 +167,7 @@ impl<T: AsRef<str>> Escapable for T {}
#[cfg(test)]
mod tests {
- use super::{Cow, Escapable, Uuid, env, in_git_repo, uuid_v7};
+ use super::{Cow, Uuid, env, in_git_repo, uuid_v7};
use std::collections::HashSet;
@@ -259,17 +262,4 @@ mod tests {
std::fs::remove_dir_all(&tmp).unwrap();
}
-
- #[test]
- fn dumb_random_test() {
- // Obviously not a test of randomness, but make sure we haven't made some
- // catastrophic error
-
- assert_ne!(crypto_random_string::<1>(), crypto_random_string::<1>());
- assert_ne!(crypto_random_string::<2>(), crypto_random_string::<2>());
- assert_ne!(crypto_random_string::<4>(), crypto_random_string::<4>());
- assert_ne!(crypto_random_string::<8>(), crypto_random_string::<8>());
- assert_ne!(crypto_random_string::<16>(), crypto_random_string::<16>());
- assert_ne!(crypto_random_string::<32>(), crypto_random_string::<32>());
- }
}