返回 DeepSeek-Reasonix
history_search_test.go
根目录 / desktop / history_search_test.go
1 package main
2
3 import (
4 "encoding/json"
5 "testing"
6
7 "reasonix/internal/provider"
8 )
9
10 func TestHistoryMessagesIncludeServerSearch(t *testing.T) {
11 got := historyMessages([]provider.Message{{
12 Role: provider.RoleAssistant,
13 Content: "answer only",
14 ServerSearch: []provider.ServerSearchCall{{
15 ID: "s1", Query: "bitcoin",
16 Results: []provider.ServerSearchHit{{Title: "新闻本文", URL: "https://example.com/a"}},
17 Raw: json.RawMessage(`[{"encrypted_content":"xxx"}]`),
18 }},
19 }}, func(content string) string { return content })
20 if len(got) != 1 || got[0].Content != "answer only" {
21 t.Fatalf("history = %+v", got)
22 }
23 if len(got[0].ServerSearch) != 1 || got[0].ServerSearch[0].ID != "s1" || got[0].ServerSearch[0].Query != "bitcoin" {
24 t.Fatalf("server search = %+v", got[0].ServerSearch)
25 }
26 if len(got[0].ServerSearch[0].Raw) != 0 {
27 t.Fatalf("history view should omit encrypted replay payload, got %s", got[0].ServerSearch[0].Raw)
28 }
29 }
30
30 lines GO