[pbs-devel] [PATCH proxmox-backup 03/23] maintenance: add 'Unpplugged' maintenance type
Lukas Wagner
l.wagner at proxmox.com
Tue Sep 19 15:37:58 CEST 2023
On 9/15/23 08:54, Hannes Laimer wrote:
> +
> +#[test]
> +fn test_check() {
> + let ro_mode = MaintenanceMode::new(MaintenanceType::ReadOnly, None);
> + let offline_mode = MaintenanceMode::new(MaintenanceType::Offline, None);
> + let delete_mode = MaintenanceMode::new(MaintenanceType::Delete, None);
> + let unplugged_mode = MaintenanceMode::new(MaintenanceType::Unplugged, None);
> +
> + assert!(ro_mode.check(Some(Operation::Lookup)).is_ok());
> + assert!(ro_mode.check(Some(Operation::Read)).is_ok());
> + assert!(ro_mode.check(Some(Operation::Write)).is_err());
> +
> + assert!(offline_mode.check(Some(Operation::Lookup)).is_ok());
> + assert!(offline_mode.check(Some(Operation::Read)).is_err());
> + assert!(offline_mode.check(Some(Operation::Write)).is_err());
> +
> + assert!(delete_mode.check(Some(Operation::Lookup)).is_err());
> + assert!(delete_mode.check(Some(Operation::Read)).is_err());
> + assert!(delete_mode.check(Some(Operation::Write)).is_err());
> +
> + assert!(unplugged_mode.check(Some(Operation::Lookup)).is_err());
> + assert!(unplugged_mode.check(Some(Operation::Read)).is_err());
> + assert!(unplugged_mode.check(Some(Operation::Write)).is_err());
> +}
It's always advisable to have tests in separate submodule:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_check() {
...
}
}
This makes sure that the test(s) is/are not compiled during a normal
build :)
--
- Lukas
More information about the pbs-devel
mailing list