tests
This commit is contained in:
72
internal/agents/tool/email/summary_test.go
Normal file
72
internal/agents/tool/email/summary_test.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package email
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
var testMessages = []Message{
|
||||
{Subject: "Rechnung März", From: "buchhaltung@firma.de", Date: "2026-03-01 09:00"},
|
||||
{Subject: "Meeting Einladung", From: "chef@firma.de", Date: "2026-03-02 10:30"},
|
||||
{Subject: "Newsletter", From: "news@shop.de", Date: "2026-03-03 08:00"},
|
||||
}
|
||||
|
||||
func TestFormatEmailList_ContainsFields(t *testing.T) {
|
||||
result := formatEmailList(testMessages)
|
||||
|
||||
checks := []string{"Rechnung März", "buchhaltung@firma.de", "Meeting Einladung", "Newsletter"}
|
||||
for _, s := range checks {
|
||||
if !strings.Contains(result, s) {
|
||||
t.Errorf("formatEmailList: fehlt %q in:\n%s", s, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatEmailList_NumberedLines(t *testing.T) {
|
||||
result := formatEmailList(testMessages)
|
||||
if !strings.Contains(result, "[1]") {
|
||||
t.Error("fehlt [1] in Ausgabe")
|
||||
}
|
||||
if !strings.Contains(result, "[3]") {
|
||||
t.Error("fehlt [3] in Ausgabe")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatEmailList_Empty(t *testing.T) {
|
||||
result := formatEmailList([]Message{})
|
||||
if result != "" {
|
||||
t.Errorf("leere Liste sollte leeren String ergeben, got: %q", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackList_ContainsWarning(t *testing.T) {
|
||||
result := fallbackList(testMessages)
|
||||
if !strings.Contains(result, "LLM nicht verfügbar") {
|
||||
t.Errorf("Fallback-Hinweis fehlt: %q", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackList_ContainsAllMessages(t *testing.T) {
|
||||
result := fallbackList(testMessages)
|
||||
for _, m := range testMessages {
|
||||
if !strings.Contains(result, m.Subject) {
|
||||
t.Errorf("Betreff fehlt: %q", m.Subject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseMessages_Empty(t *testing.T) {
|
||||
result := parseMessages(nil)
|
||||
if len(result) != 0 {
|
||||
t.Errorf("erwartet leer, got %d", len(result))
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessage_DateFormat(t *testing.T) {
|
||||
// Datum muss im Format "2006-01-02 15:04" formatiert werden
|
||||
m := testMessages[0]
|
||||
if _, err := time.Parse("2006-01-02 15:04", m.Date); err != nil {
|
||||
t.Errorf("Datumsformat ungültig: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user