From 2d29d1fe1d8ecdfba0e249f10a47acc688f77595 Mon Sep 17 00:00:00 2001 From: Wayback Archiver <66856220+waybackarchiver@users.noreply.github.com> Date: Fri, 14 Apr 2023 04:03:20 +0000 Subject: [PATCH] Fix wayback testing (#24) --- ia.go | 2 -- ia_test.go | 11 ++++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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)