This commit is contained in:
Tomas Dvorak
2026-02-24 10:33:59 +01:00
parent 409acd2e08
commit 898a3c303f
1374 changed files with 290409 additions and 29187 deletions
+33
View File
@@ -0,0 +1,33 @@
package scraper
import "testing"
func TestNormalizeDocument_TitleCleanup(t *testing.T) {
doc := &Document{
Title: "http.type CloseNotifier ¶ deprecated added in go1.1",
Content: "line 1 \n\n\nline 2",
URL: "https://pkg.go.dev/net/http#CloseNotifier",
}
NormalizeDocument(doc)
if doc.Title != "http.type CloseNotifier" {
t.Fatalf("unexpected normalized title: %q", doc.Title)
}
if doc.Content != "line 1\n\nline 2" {
t.Fatalf("unexpected normalized content: %q", doc.Content)
}
}
func TestNormalizeDocument_InferTitle(t *testing.T) {
doc := &Document{
Title: "",
URL: "https://kotlinlang.org/docs/regex.html",
}
NormalizeDocument(doc)
if doc.Title != "regex" {
t.Fatalf("expected inferred title 'regex', got %q", doc.Title)
}
}