diff options
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) } |