2026-04-14 12:00:03 +08:00
|
|
|
package instruction
|
2026-04-14 10:24:13 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
2026-04-14 12:00:03 +08:00
|
|
|
func TestAssemblerRespectsProvidedSources(t *testing.T) {
|
|
|
|
|
result := NewAssembler().Assemble(AssemblerInput{
|
2026-04-18 11:25:48 +08:00
|
|
|
AgentInstruction: "agent-rule",
|
|
|
|
|
ToolAppendices: []string{"tool-rule-1", "tool-rule-2"},
|
2026-04-14 10:24:13 +08:00
|
|
|
})
|
2026-04-18 11:25:48 +08:00
|
|
|
if !strings.Contains(result.Text, "Agent 规则:\nagent-rule") {
|
|
|
|
|
t.Fatalf("missing agent instruction: %s", result.Text)
|
2026-04-14 10:24:13 +08:00
|
|
|
}
|
|
|
|
|
if !strings.Contains(result.Text, "工具补充规则:\ntool-rule-1") {
|
|
|
|
|
t.Fatalf("missing tool appendix: %s", result.Text)
|
|
|
|
|
}
|
2026-08-28 22:23:13 +08:00
|
|
|
if !result.Summary.HasAgentRule || !result.Summary.HasToolRule {
|
2026-04-14 10:24:13 +08:00
|
|
|
t.Fatalf("unexpected summary: %#v", result.Summary)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-17 17:11:26 +08:00
|
|
|
|
2026-04-18 11:25:48 +08:00
|
|
|
func TestAssemblerReturnsEmptyTextWhenInputIsEmpty(t *testing.T) {
|
2026-04-17 17:11:26 +08:00
|
|
|
result := NewAssembler().Assemble(AssemblerInput{})
|
2026-04-18 11:05:41 +08:00
|
|
|
if result.Text != "" {
|
|
|
|
|
t.Fatalf("expected empty assembled text, got: %s", result.Text)
|
2026-04-17 17:11:26 +08:00
|
|
|
}
|
2026-08-28 22:23:13 +08:00
|
|
|
if len(result.Summary.SectionTitles) != 0 || result.Summary.HasAgentRule || result.Summary.HasToolRule {
|
2026-04-18 11:25:48 +08:00
|
|
|
t.Fatalf("expected empty summary, got %#v", result.Summary)
|
2026-04-17 17:11:26 +08:00
|
|
|
}
|
|
|
|
|
}
|