Files
pipelines/internal/protocol/result_test.go

29 lines
937 B
Go

package protocol
import (
"encoding/json"
"strings"
"testing"
)
func TestOutputPreviewUsesRetainedValuesWithoutAssumingSchema(t *testing.T) {
for _, test := range []struct {
output map[string]any
want string
}{
{map[string]any{"summary": "Fixed layout\nand added regression checks", "evidence": "details"}, "Fixed layout and added regression checks"},
{map[string]any{"artifacts": []string{"report.md"}}, `artifacts: ["report.md"]`},
{map[string]any{"z": true, "a": json.Number("9007199254740993")}, "a: 9007199254740993"},
{map[string]any{"input": map[string]any{"prompt": "private task"}}, ""},
{nil, ""},
} {
if got := OutputPreview(test.output); got != test.want {
t.Fatal(got, test.want)
}
}
preview := OutputPreview(map[string]any{"summary": strings.Repeat("宽", 500)})
if len([]rune(preview)) != 280 || !strings.HasSuffix(preview, "…") {
t.Fatal("preview is not bounded by characters")
}
}