]> git.proxmox.com Git - proxmox-backup.git/commitdiff
doc and tests fixup
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 19 Jul 2021 11:00:16 +0000 (13:00 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 19 Jul 2021 12:16:28 +0000 (14:16 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
pbs-client/src/tools/key_source.rs
pbs-tools/Cargo.toml
pbs-tools/src/xattr.rs
pbs-tools/src/zip.rs
src/tools/statistics.rs

index 340fe2343ed2e3b9dd0c21ed93d0cd1277a83a93..aeb99feb47579fe2514414d58b2f304f61c81137 100644 (file)
@@ -360,6 +360,18 @@ pub fn get_encryption_key_password() -> Result<Vec<u8>, Error> {
     bail!("no password input mechanism available");
 }
 
+#[cfg(test)]
+fn create_testdir(name: &str) -> Result<String, Error> {
+    let mut testdir: PathBuf = String::from("./target/testout").into();
+    testdir.push(std::module_path!());
+    testdir.push(name);
+
+    let _ = std::fs::remove_dir_all(&testdir);
+    let _ = std::fs::create_dir_all(&testdir);
+
+    Ok(testdir.to_str().unwrap().to_string())
+}
+
 #[test]
 // WARNING: there must only be one test for crypto_parameters as the default key handling is not
 // safe w.r.t. concurrency
@@ -373,9 +385,11 @@ fn test_crypto_parameters_handling() -> Result<(), Error> {
     let some_master_key = vec![3;1];
     let default_master_key = vec![4;1];
 
-    let keypath = "./target/testout/keyfile.test";
-    let master_keypath = "./target/testout/masterkeyfile.test";
-    let invalid_keypath = "./target/testout/invalid_keyfile.test";
+    let testdir = create_testdir("key_source")?;
+
+    let keypath = format!("{}/keyfile.test", testdir);
+    let master_keypath = format!("{}/masterkeyfile.test", testdir);
+    let invalid_keypath = format!("{}/invalid_keyfile.test", testdir);
 
     let no_key_res = CryptoParams {
         enc_key: None,
index e149f04830309573f280cff448a52b3572ae6b84..0492338dd940a696f98ed21b5d7cceb9e8fdfb6e 100644 (file)
@@ -32,3 +32,6 @@ walkdir = "2"
 proxmox = { version = "0.11.5", default-features = false, features = [ "tokio" ] }
 
 pbs-buildcfg = { path = "../pbs-buildcfg" }
+
+[dev-dependencies]
+tokio = { version = "1.6", features = [ "macros" ] }
index 500af32660306c7f93963e0e30cd89e5cd1abcee..5e7845e7824ce6813a5f120ca1a4c6dc5c6b42a6 100644 (file)
@@ -191,7 +191,7 @@ mod tests {
 
     #[test]
     fn test_fsetxattr_fgetxattr() {
-        let path = "./tests/xattrs.txt";
+        let path = "./test-xattrs.txt";
         let file = OpenOptions::new()
             .write(true)
             .create(true)
index c0bf76cd144f157674565b1338aac655970a408c..605480a8f426a4b13d24ce31b4eb948154ceccc3 100644 (file)
@@ -418,9 +418,10 @@ where
 /// 'add_entry'. To Finish the file, call 'finish'
 /// Example:
 /// ```no_run
-/// use proxmox_backup::tools::zip::*;
-/// use tokio::fs::File;
 /// use anyhow::{Error, Result};
+/// use tokio::fs::File;
+///
+/// use pbs_tools::zip::{ZipEncoder, ZipEntry};
 ///
 /// #[tokio::main]
 /// async fn main() -> Result<(), Error> {
index 2a0e429c81da81fbdc09178249677a0aa58b79fc..36e646679b92687450d83e60cb6e9f90e15f1c92 100644 (file)
@@ -79,8 +79,8 @@ where
     Some(covariance/(len_x as f64))
 }
 
-/// Returns the factors (a,b) of a linear regression y = a + bx
-/// for the variables [x,y] or None if the lists are not the same length
+/// Returns the factors `(a,b)` of a linear regression `y = a + bx`
+/// for the variables `[x,y]` or `None` if the lists are not the same length
 /// ```
 /// # use proxmox_backup::tools::statistics::linear_regression;
 ///