cli: Improve test utilities

This will allow easy creation of multiple users with deterministic keys.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2023-01-24 10:46:57 +01:00
parent 3aff91f9b7
commit b78790622f
3 changed files with 93 additions and 32 deletions
+10
View File
@@ -70,6 +70,16 @@ impl TestFormula {
self
}
pub fn envs<K: ToString, V: ToString>(
&mut self,
envs: impl IntoIterator<Item = (K, V)>,
) -> &mut Self {
for (k, v) in envs {
self.env.insert(k.to_string(), v.to_string());
}
self
}
pub fn file(&mut self, path: impl AsRef<Path>) -> Result<&mut Self, Error> {
let contents = fs::read(path)?;
self.read(io::Cursor::new(contents))