tests
This commit is contained in:
43
internal/agents/agent_test.go
Normal file
43
internal/agents/agent_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user