aboutsummaryrefslogtreecommitdiff
path: root/html_test.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-03-16 13:58:21 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2026-03-16 13:58:21 +0100
commita75ea9362403a4d9da13bca2e3c1a44814723f0b (patch)
treee314efdf03a05f0e202d027d784eb2d677c8d824 /html_test.go
parentd9b66eb7a9a9135462e490e46244dcd1b71c7293 (diff)
feat(html): retrieve human from http response
Diffstat (limited to 'html_test.go')
-rw-r--r--html_test.go25
1 files changed, 25 insertions, 0 deletions
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(`<link rel=human-json href=/human.json>`), base)