wip: checkpoint 2026-03-29 runtime work

This commit is contained in:
zyl
2026-03-29 22:44:30 +08:00
parent 7d9036b2d4
commit e294fbb9b1
30 changed files with 6759 additions and 161 deletions

View File

@@ -0,0 +1,53 @@
use std::path::PathBuf;
use std::process::Command as ProcessCommand;
use serde_json::json;
use sgclaw::compat::openxml_office_tool::OpenXmlOfficeTool;
use uuid::Uuid;
use zeroclaw::tools::Tool;
fn temp_workspace_root() -> PathBuf {
let root = std::env::temp_dir().join(format!("sgclaw-openxml-office-{}", Uuid::new_v4()));
std::fs::create_dir_all(&root).unwrap();
root
}
#[tokio::test]
async fn openxml_office_tool_renders_hotlist_xlsx_from_rows() {
let workspace_root = temp_workspace_root();
let output_path = workspace_root.join("out/zhihu-hotlist.xlsx");
let tool = OpenXmlOfficeTool::new(workspace_root.clone());
let result = tool
.execute(json!({
"sheet_name": "知乎热榜",
"columns": ["rank", "title", "heat"],
"rows": [
[1, "问题一", "344万"],
[2, "问题二", "266万"]
],
"output_path": output_path
}))
.await
.unwrap();
assert!(result.success, "{result:?}");
assert!(output_path.exists());
assert!(result.output.contains(output_path.to_str().unwrap()));
let unzip = ProcessCommand::new("unzip")
.args([
"-p",
output_path.to_str().unwrap(),
"xl/worksheets/sheet1.xml",
])
.output()
.unwrap();
assert!(unzip.status.success());
let xml = String::from_utf8(unzip.stdout).unwrap();
assert!(xml.contains("问题一"));
assert!(xml.contains("344万"));
assert!(xml.contains("问题二"));
assert!(!xml.contains("{{TITLE_1}}"));
}