Files
moteva/server/internal/infrastructure/piagent/creative_agent_test.go
T

40 lines
1.1 KiB
Go
Raw Normal View History

package piagent
import (
"strings"
"testing"
"unicode/utf8"
"img_infinite_canvas/internal/domain/design"
)
func TestNewCreativeAgentDefaultsToGPT55(t *testing.T) {
agent := NewCreativeAgent(CreativeAgentOptions{
BaseURL: "http://example.com",
APIKey: "test-key",
})
if agent == nil {
t.Fatal("expected creative agent")
}
if agent.model != "gpt-5.5" {
t.Fatalf("expected gpt-5.5 default model, got %s", agent.model)
}
}
func TestAgentMessageContentSummaryDoesNotLeakImageURLs(t *testing.T) {
summary := agentMessageContentSummary([]design.AgentChatMessage{
{
Contents: []design.AgentContent{
{Type: "text", Text: strings.Repeat("视觉方向", 200)},
{Type: "image", ImageURL: "https://storage.example.com/private/raw.png", ImageWidth: 100, ImageHeight: 200},
},
},
})
if strings.Contains(summary, "storage.example.com") || strings.Contains(summary, "raw.png") {
t.Fatalf("expected compact image reference without raw URL, got %s", summary)
}
if utf8.RuneCountInString(summary) > 360 {
t.Fatalf("expected compact inline text summary, got %d runes", utf8.RuneCountInString(summary))
}
}