Files
sundynix-agentix/sundynix-mcp-go/internal/mcp/report_test.go
T
Blizzard 9b0520e020 test(backend): 编排引擎/DSL/docx/报告导出 首批 Go 单测(19 用例,纯逻辑无依赖)
补齐核心后端逻辑的自动化测试,全部纯函数级、不依赖 docker/NATS/LLM,毫秒级跑完,
把"手动起全栈 curl 验证"变成 `go test`:

- dispatcher/internal/eino (graph_test.go)
  evalCondition(各运算符+refs/tools/answer/profile 关键字+兜底)、resolveOperand、
  aggregate(拼接/去重合并/默认/全空)、branchNode(真假边标签精确选路 + 无标签退回边序 +
  单边剪枝)、cstr/cbool/countLines/labelOf/targetsOf。
- dispatcher/internal/dsl (compile_test.go)
  Topo(线性序 + 有环不丢节点)、Compile(system/query/tools 抽取 + 无输入兜底 + 空图用原文)、
  ToolBinding(tool/retriever/非工具)、Parse(合法/非法)。
- mcp-go/internal/office (unioffice_test.go)
  RenderReport 产物为合法 docx(zip 三部件 + 标题/章节文本 + XML 转义)、escapeXML。
- mcp-go/internal/mcp (report_test.go)
  reportMarkdown(标题+多章 / 无标题)。
- gateway/internal/dsl (parser_test.go)
  ParseAndAssemble(task_ 前缀 + Graph 透传 + Meta 初始化 + 空/非法报错)。

`go test ./...` 各模块全绿。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 14:13:13 +08:00

31 lines
747 B
Go

package mcp
import (
"testing"
"github.com/sundynix/sundynix-mcp-go/internal/office"
)
func TestReportMarkdown(t *testing.T) {
src := reportSource{
Title: "咖啡",
Sections: []office.Section{
{Heading: "提神", Body: " 含咖啡因 "},
{Heading: "风险", Body: "过量失眠"},
},
}
got := reportMarkdown(src)
want := "# 咖啡\n\n## 提神\n\n含咖啡因\n\n## 风险\n\n过量失眠\n\n"
if got != want {
t.Errorf("reportMarkdown =\n%q\nwant\n%q", got, want)
}
}
func TestReportMarkdown_NoTitle(t *testing.T) {
got := reportMarkdown(reportSource{Sections: []office.Section{{Heading: "H", Body: "B"}}})
want := "## H\n\nB\n\n"
if got != want {
t.Errorf("无标题 reportMarkdown = %q, want %q", got, want)
}
}