46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package agent
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"ollie/cmd/olliesrv/internal/backend"
|
|
)
|
|
|
|
func messageWithContent(callID, content string) backend.Message {
|
|
return backend.Message{Role: "tool", ToolCallID: callID, Content: content}
|
|
}
|
|
|
|
func TestNormalizeSummaryCacheContentPlainText(t *testing.T) {
|
|
got := normalizeSummaryCacheContent(" first line \r\n\r\n\nsecond line \t\n\n")
|
|
if got != "first line\n\nsecond line" {
|
|
t.Fatalf("normalized content = %q", got)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeSummaryCacheContentPreservesStructuredContent(t *testing.T) {
|
|
content := "{\r\n \"key\": \"value\"\r\n}\r\n"
|
|
if got := normalizeSummaryCacheContent(content); got != content {
|
|
t.Fatalf("structured content changed: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestToolSummaryHashIgnoresToolCallID(t *testing.T) {
|
|
first := toolSummaryHash(messageWithContent("first-call", "same result\n"))
|
|
second := toolSummaryHash(messageWithContent("second-call", "same result"))
|
|
if first != second {
|
|
t.Fatalf("hashes differ for identical content: %q != %q", first, second)
|
|
}
|
|
if !strings.HasPrefix(first, "cold-summary:v2:") {
|
|
t.Fatalf("hash missing version prefix: %q", first)
|
|
}
|
|
}
|
|
|
|
func TestToolSummaryHashSeparatesContent(t *testing.T) {
|
|
first := toolSummaryHash(messageWithContent("call", "first result"))
|
|
second := toolSummaryHash(messageWithContent("call", "second result"))
|
|
if first == second {
|
|
t.Fatal("different content produced the same hash")
|
|
}
|
|
}
|