diff --git a/proxmox-api/src/format.rs b/proxmox-api/src/format.rs index 16f3c17c..484ad580 100644 --- a/proxmox-api/src/format.rs +++ b/proxmox-api/src/format.rs @@ -48,15 +48,26 @@ pub fn wrap_text( .filter(|p| !p.is_empty()) .fold(String::new(), |mut acc, p| { if acc.is_empty() { - acc.push_str(&wrapper1.wrap(p).concat()); + acc.push_str(&wrapper1.wrap(p).join("\n")); } else { - acc.push_str(&wrapper2.wrap(p).concat()); + acc.push_str(&wrapper2.wrap(p).join("\n")); } acc.push_str("\n\n"); acc }) } +#[test] +fn test_wrap_text() { + let text = "Command. This may be a list in order to spefify nested sub-commands."; + let expect = " Command. This may be a list in order to spefify nested sub-\n commands.\n\n"; + + let indent = " "; + let wrapped = wrap_text(indent, indent, text, 80); + + assert_eq!(wrapped, expect); +} + /// TODO: Document output format. pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> String { match schema {