[pve-devel] [PATCH installer v3 14/20] auto-installer: tests: replace `PathBuf` parameters with `AsRef<Path>`

Christoph Heiss c.heiss at proxmox.com
Wed Aug 21 11:40:16 CEST 2024


Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
Changes v2 -> v3:
  * no changes

Changes v1 -> v2:
  * new patch, suggestion by Stefan

 proxmox-auto-installer/tests/parse-answer.rs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/proxmox-auto-installer/tests/parse-answer.rs b/proxmox-auto-installer/tests/parse-answer.rs
index 72bddaa..0e5d6e7 100644
--- a/proxmox-auto-installer/tests/parse-answer.rs
+++ b/proxmox-auto-installer/tests/parse-answer.rs
@@ -18,7 +18,7 @@ fn get_test_resource_path() -> Result<PathBuf, String> {
         .join("tests/resources"))
 }
 
-fn get_answer(path: PathBuf) -> Result<Answer, String> {
+fn get_answer(path: impl AsRef<Path>) -> Result<Answer, String> {
     let answer_raw = std::fs::read_to_string(path).unwrap();
     let answer: answer::Answer = toml::from_str(&answer_raw)
         .map_err(|err| format!("error parsing answer.toml: {err}"))
@@ -27,11 +27,12 @@ fn get_answer(path: PathBuf) -> Result<Answer, String> {
     Ok(answer)
 }
 
-pub fn setup_test_basic(path: &Path) -> (SetupInfo, LocaleInfo, RuntimeInfo, UdevInfo) {
-    let (installer_info, locale_info, mut runtime_info) = load_installer_setup_files(path).unwrap();
+pub fn setup_test_basic(path: impl AsRef<Path>) -> (SetupInfo, LocaleInfo, RuntimeInfo, UdevInfo) {
+    let (installer_info, locale_info, mut runtime_info) =
+        load_installer_setup_files(&path).unwrap();
 
     let udev_info: UdevInfo = {
-        let mut path = path.to_path_buf();
+        let mut path = path.as_ref().to_path_buf();
         path.push("run-env-udev.json");
 
         read_json(&path)
-- 
2.45.2





More information about the pve-devel mailing list