feat: Поиск - with it on the assistant searches DuckDuckGo itself and answers from what it found; without it, it cannot. «Думал N сек.»
This commit is contained in:
1 parent
fa62f2c5b6
commit
9bf30b281e
8 files changed
+921
-7
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The results of DuckDuckGo's light page: titles, real addresses (not its
|
||||
// redirects), snippets without tags.
|
||||
func TestParseDDGLite(t *testing.T) {
|
||||
b, err := os.ReadFile("testdata/ddg_lite.html")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rs := parseDDG(string(b))
|
||||
if len(rs) < 5 {
|
||||
t.Fatalf("results: %d", len(rs))
|
||||
}
|
||||
r := rs[0]
|
||||
if r.URL != "https://go.dev/doc/database/cancel-operations" || !strings.Contains(r.Title, "Canceling in-progress operations") ||
|
||||
!strings.Contains(r.Snippet, "Learn how to use context.Context") || strings.Contains(r.Snippet, "<b>") {
|
||||
t.Fatalf("first: %+v", r)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user