aboutsummaryrefslogtreecommitdiff
path: root/html_test.go
diff options
context:
space:
mode:
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)