test: update message preparation tests to expect explicit User role markers

This commit is contained in:
CJACK
2026-03-29 19:41:03 +08:00
parent aeb519c211
commit 621599f8ad
2 changed files with 8 additions and 5 deletions

View File

@@ -12,7 +12,7 @@ func TestMessagesPrepareBasic(t *testing.T) {
if got == "" {
t.Fatal("expected non-empty prompt")
}
if got != "Hello" {
if got != "<User>Hello" {
t.Fatalf("unexpected prompt: %q", got)
}
}
@@ -55,7 +55,7 @@ func TestMessagesPrepareArrayTextVariants(t *testing.T) {
},
}
got := MessagesPrepare(messages)
if got != "line1\nline2" {
if got != "<User>line1\nline2" {
t.Fatalf("unexpected content from text variants: %q", got)
}
}

View File

@@ -162,13 +162,16 @@ func TestMessagesPrepareMergesConsecutiveSameRole(t *testing.T) {
{"role": "user", "content": "World"},
}
got := MessagesPrepare(messages)
if !strings.HasPrefix(got, "<User>") {
t.Fatalf("expected user marker at the start, got %q", got)
}
if !strings.Contains(got, "Hello") || !strings.Contains(got, "World") {
t.Fatalf("expected both messages, got %q", got)
}
// Should be merged without <User> between them
// Should be merged into a single user turn with one marker at the start.
count := strings.Count(got, "<User>")
if count != 0 {
t.Fatalf("expected no User marker for first message pair, got %d occurrences", count)
if count != 1 {
t.Fatalf("expected one User marker for the merged pair, got %d occurrences", count)
}
}