testdata: Initial action/challenges testing

This commit is contained in:
WeebDataHoarder
2025-04-29 05:06:46 +02:00
parent 467ad9c5a9
commit 6a6c3fef07
9 changed files with 889 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ package utils
import (
"golang.org/x/net/html"
"io"
"mime"
"net/http"
"net/http/httptest"
@@ -32,8 +33,12 @@ func FetchTags(backend http.Handler, uri *url.URL, kind string) (result []html.N
return nil
}
return FetchTagsFromReader(response.Body, kind)
}
func FetchTagsFromReader(r io.Reader, kind string) (result []html.Node) {
//TODO: handle non UTF-8 documents
node, err := html.ParseWithOptions(response.Body, html.ParseOptionEnableScripting(false))
node, err := html.ParseWithOptions(r, html.ParseOptionEnableScripting(false))
if err != nil {
return nil
}