#![allow(dead_code)]
pub mod assertions;
pub mod commands;
pub mod fixtures;
pub mod skip;
#[allow(unused_imports)]
pub use assertions::*;
#[allow(unused_imports)]
pub use fixtures::*;
use tempfile::TempDir;
pub struct Test {
pub dir: TempDir,
pub home: TempDir,
}
impl Test {
pub fn new() -> Self {
let dir = TempDir::new().expect("failed to create temp dir");
let home = TempDir::new().expect("failed to create temp home");
Self { dir, home }
}
pub fn init(name: &str) -> Self {
let t = Self::new();
let output = t.init_cmd(name);
assert!(
output.status.success(),
"Failed to initialize vault: {}",
String::from_utf8_lossy(&output.stderr)
);
t
}
pub fn with_secrets(name: &str, secrets: &[(&str, &str)]) -> Self {
let t = Self::init(name);
for (k, v) in secrets {
let output = t.set(k, v);
assert!(
output.status.success(),
"Failed to set secret {}: {}",
k,
String::from_utf8_lossy(&output.stderr)
);
}
t
}
}