Files
ai-agent/internal/agents/agent_test.go
Christoph K. b1a576f61e tests
2026-03-20 07:08:00 +01:00

44 lines
1003 B
Go

package agents
import "testing"
func TestHistoryMessage_Fields(t *testing.T) {
h := HistoryMessage{Role: "user", Content: "Hallo"}
if h.Role != "user" {
t.Errorf("Role: %q", h.Role)
}
if h.Content != "Hallo" {
t.Errorf("Content: %q", h.Content)
}
}
func TestRequest_HistoryAppend(t *testing.T) {
req := Request{
Action: ActionQuery,
Args: []string{"Frage"},
History: []HistoryMessage{
{Role: "user", Content: "Vorherige Frage"},
{Role: "assistant", Content: "Vorherige Antwort"},
},
}
if len(req.History) != 2 {
t.Errorf("History len: %d", len(req.History))
}
if req.History[0].Role != "user" {
t.Errorf("erstes Element: %q", req.History[0].Role)
}
}
func TestResponse_RawAnswer(t *testing.T) {
resp := Response{
Text: "**Formatierte** Antwort",
RawAnswer: "Formatierte Antwort",
}
if resp.RawAnswer == "" {
t.Error("RawAnswer sollte gesetzt sein")
}
if resp.Text == resp.RawAnswer {
t.Error("Text und RawAnswer sollten sich unterscheiden")
}
}