diff --git a/ia.go b/ia.go index d8efb64..79ca6c0 100644 --- a/ia.go +++ b/ia.go @@ -115,8 +115,6 @@ func (wbrc *Archiver) archive(ctx context.Context, u *url.URL) (string, error) { return fmt.Sprint(loc), nil } - logger.Error("The Internet Archive: %s for url: %s", resp.Status, base+uri) - return loc, nil } diff --git a/ia_test.go b/ia_test.go index 6807122..e051d65 100644 --- a/ia_test.go +++ b/ia_test.go @@ -21,12 +21,21 @@ const available = `{ }` func TestWayback(t *testing.T) { + httpClient, mux, server := helper.MockServer() + defer server.Close() + + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/wayback/available" { + _, _ = w.Write([]byte(available)) + } + }) + uri := "https://example.com" u, err := url.Parse(uri) if err != nil { t.Fatal(err) } - wbrc := &Archiver{} + wbrc := &Archiver{Client: httpClient} got, err := wbrc.Wayback(context.Background(), u) if err != nil { t.Log(got)