From a75ea9362403a4d9da13bca2e3c1a44814723f0b Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Mon, 16 Mar 2026 13:58:21 +0100 Subject: feat(html): retrieve human from http response --- html_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'html_test.go') diff --git a/html_test.go b/html_test.go index ab2bda7..b7fdf1a 100644 --- a/html_test.go +++ b/html_test.go @@ -1,10 +1,35 @@ package human import ( + "context" + "encoding/json" + "net/http" "net/url" "testing" ) +func TestGetHumanFromHTML(t *testing.T) { + client := http.DefaultClient + // using human.json author's website + resp, err := client.Get(`https://robida.net/`) + if err != nil { + t.Fatal(err) + } + t.Logf("html fetched") + h, err := GetHumanFromHTML(context.Background(), client, resp) + if err != nil { + t.Fatal(err) + } + if h == nil { + t.Fatal("human.json is nil") + } + b, err := json.Marshal(h) + if err != nil { + t.Fatal(err) + } + t.Logf("%s", b) +} + func TestGetURLFromHTML(t *testing.T) { base, _ := url.Parse(`https://example.org/foo/`) u, err := GetURLFromHTML([]byte(``), base) -- cgit v1.2.3