use super::super::BackupCreateReport;
use canic_host::table::{ColumnAlign, render_table};
pub(super) fn render_create_report(report: &BackupCreateReport) -> String {
let rows = [[
report.deployment.clone(),
report.network.clone(),
report.mode.clone(),
report.layout.clone(),
report.status.clone(),
report.scope.clone(),
report.targets.to_string(),
report.operations.to_string(),
report.executed_operations.to_string(),
report.out.display().to_string(),
]];
render_table(
&[
"DEPLOYMENT",
"NETWORK",
"MODE",
"LAYOUT",
"STATUS",
"SCOPE",
"TARGETS",
"OPERATIONS",
"EXECUTED",
"OUT",
],
&rows,
&[ColumnAlign::Left; 10],
)
}
#[cfg(test)]
mod tests {
use super::*;
use std::path::PathBuf;
#[test]
fn render_backup_create_report_shows_layout_source() {
let report = BackupCreateReport {
deployment: "demo".to_string(),
network: "local".to_string(),
out: PathBuf::from("backups/demo"),
plan_id: "plan-demo".to_string(),
run_id: "run-demo".to_string(),
mode: "dry-run".to_string(),
layout: "existing".to_string(),
status: "planned".to_string(),
scope: "non-root-deployment".to_string(),
targets: 2,
operations: 3,
executed_operations: 0,
};
let text = render_create_report(&report);
assert!(text.contains("DEPLOYMENT"));
assert!(!text.contains("FLEET"));
assert!(text.contains("LAYOUT"));
assert!(text.contains("existing"));
}
}