Skip to content

Commit 621599f

Browse files
committed
test: update message preparation tests to expect explicit User role markers
1 parent aeb519c commit 621599f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

internal/util/messages_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func TestMessagesPrepareBasic(t *testing.T) {
1212
if got == "" {
1313
t.Fatal("expected non-empty prompt")
1414
}
15-
if got != "Hello" {
15+
if got != "<|User|>Hello" {
1616
t.Fatalf("unexpected prompt: %q", got)
1717
}
1818
}
@@ -55,7 +55,7 @@ func TestMessagesPrepareArrayTextVariants(t *testing.T) {
5555
},
5656
}
5757
got := MessagesPrepare(messages)
58-
if got != "line1\nline2" {
58+
if got != "<|User|>line1\nline2" {
5959
t.Fatalf("unexpected content from text variants: %q", got)
6060
}
6161
}

internal/util/util_edge_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,16 @@ func TestMessagesPrepareMergesConsecutiveSameRole(t *testing.T) {
162162
{"role": "user", "content": "World"},
163163
}
164164
got := MessagesPrepare(messages)
165+
if !strings.HasPrefix(got, "<|User|>") {
166+
t.Fatalf("expected user marker at the start, got %q", got)
167+
}
165168
if !strings.Contains(got, "Hello") || !strings.Contains(got, "World") {
166169
t.Fatalf("expected both messages, got %q", got)
167170
}
168-
// Should be merged without <|User|> between them
171+
// Should be merged into a single user turn with one marker at the start.
169172
count := strings.Count(got, "<|User|>")
170-
if count != 0 {
171-
t.Fatalf("expected no User marker for first message pair, got %d occurrences", count)
173+
if count != 1 {
174+
t.Fatalf("expected one User marker for the merged pair, got %d occurrences", count)
172175
}
173176
}
174177

0 commit comments

Comments
 (0)