diff options
author | Jordan <me@jordan.im> | 2022-03-24 12:02:08 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2022-03-24 12:02:08 -0700 |
commit | 20d95915298391ea05054238c5b13337499b7af4 (patch) | |
tree | 024c080f319fc7a430343eda96ff620ed7d1febb /analysis | |
parent | 6355aa4310ff0c32b056580e812ca6f0e2a5ee2f (diff) | |
download | crawl-20d95915298391ea05054238c5b13337499b7af4.tar.gz crawl-20d95915298391ea05054238c5b13337499b7af4.zip |
misc: update handler signatures, tests, housekeeping
Diffstat (limited to 'analysis')
-rw-r--r-- | analysis/links_test.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/analysis/links_test.go b/analysis/links_test.go index 1bd906b..e108c7a 100644 --- a/analysis/links_test.go +++ b/analysis/links_test.go @@ -2,9 +2,11 @@ package analysis import ( "fmt" + "io" "io/ioutil" "net/http" "net/url" + "os" "strings" "testing" @@ -31,7 +33,24 @@ type testdata struct { } func (td *testdata) runTestCase() error { - links, err := GetLinks(makeResponse(td.ctype, td.body)) + r, err := ioutil.TempFile("temp", "crawl") + if err != nil { + return err + } + defer os.Remove(r.Name()) + + w, err := os.OpenFile(r.Name(), os.O_RDWR, 0777) + if err != nil { + return err + } + resp := makeResponse(td.ctype, td.body) + if _, err := io.Copy(w, resp.Body); err != nil { + return err + } + if _, err := r.Seek(0, io.SeekStart); err != nil { + return err + } + links, err := GetLinks(resp, r) if err != nil { return fmt.Errorf("GetLinks() error: %v", err) } |