doc and tests fixup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-07-19 13:00:16 +02:00
parent 2b7f8dd5ea
commit a3399f4337
5 changed files with 26 additions and 8 deletions

View 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,

View 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" ] }

View 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)

View 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> {

View 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;
///