tape/inventory: fix the tape tests as user, by mocking the lock

locking during the tests as regular user failed because we try to
chown to the backup user (which is not always possible).

Instead, do not lock at all, by implementing 'open_backup_lockfile' with
'create_mocked_lock'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-09-06 17:00:26 +02:00 committed by Wolfgang Bumiller
parent ebf34e7edd
commit f46806414a

View File

@ -40,7 +40,20 @@ use proxmox::tools::{
};
use pbs_systemd::time::compute_next_event;
use pbs_config::{open_backup_lockfile, BackupLockGuard};
use pbs_config::BackupLockGuard;
#[cfg(not(test))]
use pbs_config::open_backup_lockfile;
#[cfg(test)]
fn open_backup_lockfile<P: AsRef<std::path::Path>>(
_path: P,
_timeout: Option<std::time::Duration>,
_exclusive: bool,
) -> Result<pbs_config::BackupLockGuard, anyhow::Error> {
Ok(unsafe { pbs_config::create_mocked_lock() })
}
use crate::{
api2::types::{