32 lines
1.2 KiB
Go
32 lines
1.2 KiB
Go
package squad
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/agent"
|
|
)
|
|
|
|
func TestStepOutputAccepted_DiskContentBeatsMissingDeliverable(t *testing.T) {
|
|
missing := &agent.Result{Success: false, ErrorReason: "missing target deliverable output.md"}
|
|
if !stepOutputAccepted(nil, nil, true, "# 调研报告\n正文", missing) {
|
|
t.Fatal("non-empty file must be accepted when the runner only reported a missing deliverable")
|
|
}
|
|
truncated := &agent.Result{Success: false, ErrorReason: "Connection error.", Retryable: true}
|
|
if stepOutputAccepted(nil, nil, true, "# partial", truncated) {
|
|
t.Fatal("retryable connection failure must stay fail-closed even if a file exists")
|
|
}
|
|
if stepOutputAccepted(nil, nil, true, " \n", missing) {
|
|
t.Fatal("blank content must not override a failed runner result")
|
|
}
|
|
if stepOutputAccepted(errors.New("backend"), nil, true, "# 调研报告", missing) {
|
|
t.Fatal("execute error must reject the step")
|
|
}
|
|
if stepOutputAccepted(nil, errors.New("materialize"), true, "# 调研报告", &agent.Result{Success: true}) {
|
|
t.Fatal("materialize error must reject the step")
|
|
}
|
|
if !stepOutputAccepted(nil, nil, false, "", &agent.Result{Success: true}) {
|
|
t.Fatal("runner success without a new file still counts")
|
|
}
|
|
}
|